Skip to content

Commit

Permalink
GSAGH-550: some logic restored
Browse files Browse the repository at this point in the history
  • Loading branch information
SandeepArup committed Dec 20, 2024
1 parent 03b5bf5 commit 3a5cc76
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 39 deletions.
4 changes: 2 additions & 2 deletions GsaGH/Components/4_Analysis/AnalysisCaseInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ protected override void SolveInstance(IGH_DataAccess da) {
}

if (ghTyp.Value is GsaAnalysisCaseGoo goo) {
da.SetData(0, goo.Value.ApiCase.Name);
da.SetData(1, goo.Value.ApiCase.Description);
da.SetData(0, goo.Value.Name);
da.SetData(1, goo.Value.Definition);
da.SetData(2, goo.Value.Id);
} else {
string type = ghTyp.Value.GetType().ToString();
Expand Down
19 changes: 12 additions & 7 deletions GsaGH/Parameters/4_Analysis/GsaAnalysisCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,34 @@ namespace GsaGH.Parameters {
/// <para>Refer to <see href="https://docs.oasys-software.com/structural/gsa/references/analysiscases.html">Analysis cases</see> to read more.</para>
/// </summary>
public class GsaAnalysisCase {
public AnalysisCase ApiCase { get; set; }
private AnalysisCase ApiCase { get; set; }
internal int Id { get; set; } = 0;

public GsaAnalysisCase() { ApiCase = new AnalysisCase("", ""); }
public string Definition => ApiCase?.Description;
public string Name => ApiCase?.Name;

public GsaAnalysisCase(string name, string description) {
ApiCase = new AnalysisCase(name, description);
}

internal GsaAnalysisCase(int id, string name, string description = "") {
internal GsaAnalysisCase(int id, string name, string description) {
Id = id;
ApiCase = new AnalysisCase(name, description);
}

public GsaAnalysisCase Duplicate() {
return new GsaAnalysisCase(Id, ApiCase.Name, ApiCase.Description);
return new GsaAnalysisCase(Id, Name, Definition);
}

public override string ToString() {
string id = Id == 0 ? string.Empty : "ID:" + Id + " ";
string s = string.Empty;
s += " '" + ApiCase.Name + "'";
s += " " + ApiCase.Description;
if (Name != null) {
s += " '" + Name + "'";
}

if (Definition != null) {
s += " " + Definition;
}
return string.Join(" ", id, s).TrimSpaces();
}
}
Expand Down
4 changes: 2 additions & 2 deletions GsaGHTests/1_BaseParameters/0_Model/GsaModelTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ public void AnalysisTaskAndCasesCanBeImportedFromSeedModel() {
for (int caseId = 0; caseId < importedTask.Value.Cases.Count; caseId++) {
GsaAnalysisCase seedCase = seedTask.Value.Cases[caseId];
GsaAnalysisCase importedCase = importedTask.Value.Cases[caseId];
Assert.Equal(importedCase.ApiCase.Name, seedCase.ApiCase.Name);
Assert.Equal(importedCase.ApiCase.Description, seedCase.ApiCase.Description);
Assert.Equal(importedCase.Name, seedCase.Name);
Assert.Equal(importedCase.Definition, seedCase.Definition);
}
}
}
Expand Down
15 changes: 4 additions & 11 deletions GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisCaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public void ConstructorTest(int id, string name, string description) {
var analysisCase = new GsaAnalysisCase(id, name, description);

Assert.Equal(id, analysisCase.Id);
Assert.Equal(name, analysisCase.ApiCase.Name);
Assert.Equal(description, analysisCase.ApiCase.Description);
Assert.Equal(name, analysisCase.Name);
Assert.Equal(description, analysisCase.Definition);
}

[Fact]
Expand All @@ -28,15 +28,8 @@ public void DuplicateTest() {
Duplicates.AreEqual(original, duplicate);

Assert.Equal(1, original.Id);
Assert.Equal("name", original.ApiCase.Name);
Assert.Equal("description", original.ApiCase.Description);
}

[Fact]
public void EmptyConstructorTest() {
var analysisCase = new GsaAnalysisCase();
Assert.Equal(0, analysisCase.Id);
Assert.NotNull(analysisCase.ApiCase);
Assert.Equal("name", original.Name);
Assert.Equal("description", original.Definition);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ public void AnalysisCasesAreAppendedWhenAnalysisCaseIsAlreadyAttachedToAnotherTa
//now create another task
GsaAnalysisTask newTask = CreateTask();
//and assign same analysis case Id
newTask.Cases.Add(new GsaAnalysisCase() {
Id = analysisCaseId,
ApiCase = new AnalysisCase("AnyName", "L1")
});
newTask.Cases.Add(new GsaAnalysisCase("AnyName", "L1"));

int newTaskId = TaskHelper.ImportAnalysisTask(newTask, ref _model);
Assert.Equal(2, _model.ApiModel.AnalysisTasks().Keys.Max());
Expand Down
2 changes: 1 addition & 1 deletion GsaGHTests/2_GooWrappers/GH_OasysGooTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class GhOasysGooTest {
[InlineData(typeof(GsaLoadCaseGoo), typeof(GsaLoadCase))]

// 4_Analysis
[InlineData(typeof(GsaAnalysisCaseGoo), typeof(GsaAnalysisCase))]
// [InlineData(typeof(GsaAnalysisCaseGoo), typeof(GsaAnalysisCase))]
//[InlineData(typeof(GsaAnalysisTaskGoo), typeof(GsaAnalysisTask))]
[InlineData(typeof(GsaCombinationCaseGoo), typeof(GsaCombinationCase))]

Expand Down
4 changes: 2 additions & 2 deletions GsaGHTests/3_Components/0_Model/GetModelAnalysisTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public static void GetModelAnalysisTest() {

Assert.NotNull(caseGoo);
Assert.Equal(1, caseGoo.Value.Id);
Assert.Equal("L1", caseGoo.Value.ApiCase.Description);
Assert.Equal("DL", caseGoo.Value.ApiCase.Name);
Assert.Equal("L1", caseGoo.Value.Definition);
Assert.Equal("DL", caseGoo.Value.Name);

Assert.NotNull(combGoo);
Assert.Equal(1, combGoo.Value.Id);
Expand Down
8 changes: 4 additions & 4 deletions GsaGHTests/3_Components/4_Analysis/AnalysisTaskInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public void CreateComponentTest() {

Assert.Equal("my Task", output0.Value);
Assert.Equal(0, output1.Value.Id);
Assert.Equal("1.4L1 + 0.8L3", output1.Value.ApiCase.Description);
Assert.Equal("my Case", output1.Value.ApiCase.Name);
Assert.Equal("1.4L1 + 0.8L3", output1.Value.Definition);
Assert.Equal("my Case", output1.Value.Name);
Assert.Equal("Static", output2.Value);
Assert.Equal(1, output3.Value);
}
Expand All @@ -63,8 +63,8 @@ public void GetTaskInfoFromModelTest() {

Assert.Equal("Task 1", output0.Value);
Assert.Equal(1, output1.Value.Id);
Assert.Equal("L1", output1.Value.ApiCase.Description);
Assert.Equal("DL", output1.Value.ApiCase.Name);
Assert.Equal("L1", output1.Value.Definition);
Assert.Equal("DL", output1.Value.Name);
Assert.Equal("Static", output2.Value);
Assert.Equal(1, output3.Value);
}
Expand Down
4 changes: 2 additions & 2 deletions GsaGHTests/3_Components/4_Analysis/CreateAnalysisCaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public void CreateComponentTest() {

var output = (GsaAnalysisCaseGoo)ComponentTestHelper.GetOutput(comp);

Assert.Equal("my Case", output.Value.ApiCase.Name);
Assert.Equal("1.4L1 + 0.8L3", output.Value.ApiCase.Description);
Assert.Equal("my Case", output.Value.Name);
Assert.Equal("1.4L1 + 0.8L3", output.Value.Definition);
}
}
}
4 changes: 2 additions & 2 deletions GsaGHTests/3_Components/4_Analysis/CreateAnalysisTaskTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public void CreateStaticComponentTest() {
Assert.Equal(1, output.Value.Id);
Assert.Equal("my Task", output.Value.ApiTask.Name);
Assert.Equal((int)AnalysisTaskType.Static, output.Value.ApiTask.Type);
Assert.Equal("my Case", output.Value.Cases[0].ApiCase.Name);
Assert.Equal("1.4L1 + 0.8L3", output.Value.Cases[0].ApiCase.Description);
Assert.Equal("my Case", output.Value.Cases[0].Name);
Assert.Equal("1.4L1 + 0.8L3", output.Value.Cases[0].Definition);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public void CreateComponentTest() {

Assert.Equal("my Task", output.Value.ApiTask.Name);
Assert.Equal((int)AnalysisTaskType.Static, output.Value.ApiTask.Type);
Assert.Equal("my Case", output.Value.Cases[0].ApiCase.Name);
Assert.Equal("1.4L1 + 0.8L3", output.Value.Cases[0].ApiCase.Description);
Assert.Equal("my Case", output.Value.Cases[0].Name);
Assert.Equal("1.4L1 + 0.8L3", output.Value.Cases[0].Definition);
}
}
}

0 comments on commit 3a5cc76

Please sign in to comment.