From 3a5cc76dcac843ee8f00a86a6a797fb151ba5d79 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Sat, 21 Dec 2024 00:50:22 +0530 Subject: [PATCH] GSAGH-550: some logic restored --- .../Components/4_Analysis/AnalysisCaseInfo.cs | 4 ++-- .../Parameters/4_Analysis/GsaAnalysisCase.cs | 19 ++++++++++++------- .../1_BaseParameters/0_Model/GsaModelTest.cs | 4 ++-- .../4_Analysis/GsaAnalysisCaseTest.cs | 15 ++++----------- .../4_Analysis/GsaAnalysisTaskTest.cs | 5 +---- GsaGHTests/2_GooWrappers/GH_OasysGooTest.cs | 2 +- .../0_Model/GetModelAnalysisTests.cs | 4 ++-- .../4_Analysis/AnalysisTaskInfoTests.cs | 8 ++++---- .../4_Analysis/CreateAnalysisCaseTests.cs | 4 ++-- .../4_Analysis/CreateAnalysisTaskTests.cs | 4 ++-- .../CreateAnalysisTaskTests_OBSOLETE.cs | 4 ++-- 11 files changed, 34 insertions(+), 39 deletions(-) diff --git a/GsaGH/Components/4_Analysis/AnalysisCaseInfo.cs b/GsaGH/Components/4_Analysis/AnalysisCaseInfo.cs index 360b20200..d92672af7 100644 --- a/GsaGH/Components/4_Analysis/AnalysisCaseInfo.cs +++ b/GsaGH/Components/4_Analysis/AnalysisCaseInfo.cs @@ -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(); diff --git a/GsaGH/Parameters/4_Analysis/GsaAnalysisCase.cs b/GsaGH/Parameters/4_Analysis/GsaAnalysisCase.cs index d463b5d35..0f8ecce80 100644 --- a/GsaGH/Parameters/4_Analysis/GsaAnalysisCase.cs +++ b/GsaGH/Parameters/4_Analysis/GsaAnalysisCase.cs @@ -10,29 +10,34 @@ namespace GsaGH.Parameters { /// Refer to Analysis cases to read more. /// 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(); } } diff --git a/GsaGHTests/1_BaseParameters/0_Model/GsaModelTest.cs b/GsaGHTests/1_BaseParameters/0_Model/GsaModelTest.cs index f8fa9899c..06896ee78 100644 --- a/GsaGHTests/1_BaseParameters/0_Model/GsaModelTest.cs +++ b/GsaGHTests/1_BaseParameters/0_Model/GsaModelTest.cs @@ -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); } } } diff --git a/GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisCaseTest.cs b/GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisCaseTest.cs index 750833c78..10e7d2301 100644 --- a/GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisCaseTest.cs +++ b/GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisCaseTest.cs @@ -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] @@ -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); } } } diff --git a/GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisTaskTest.cs b/GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisTaskTest.cs index cc170934f..3cfd369d8 100644 --- a/GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisTaskTest.cs +++ b/GsaGHTests/1_BaseParameters/4_Analysis/GsaAnalysisTaskTest.cs @@ -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()); diff --git a/GsaGHTests/2_GooWrappers/GH_OasysGooTest.cs b/GsaGHTests/2_GooWrappers/GH_OasysGooTest.cs index 3369503e8..7fd0477b8 100644 --- a/GsaGHTests/2_GooWrappers/GH_OasysGooTest.cs +++ b/GsaGHTests/2_GooWrappers/GH_OasysGooTest.cs @@ -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))] diff --git a/GsaGHTests/3_Components/0_Model/GetModelAnalysisTests.cs b/GsaGHTests/3_Components/0_Model/GetModelAnalysisTests.cs index f8341a134..864269bbd 100644 --- a/GsaGHTests/3_Components/0_Model/GetModelAnalysisTests.cs +++ b/GsaGHTests/3_Components/0_Model/GetModelAnalysisTests.cs @@ -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); diff --git a/GsaGHTests/3_Components/4_Analysis/AnalysisTaskInfoTests.cs b/GsaGHTests/3_Components/4_Analysis/AnalysisTaskInfoTests.cs index a8ec2608c..4745bca15 100644 --- a/GsaGHTests/3_Components/4_Analysis/AnalysisTaskInfoTests.cs +++ b/GsaGHTests/3_Components/4_Analysis/AnalysisTaskInfoTests.cs @@ -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); } @@ -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); } diff --git a/GsaGHTests/3_Components/4_Analysis/CreateAnalysisCaseTests.cs b/GsaGHTests/3_Components/4_Analysis/CreateAnalysisCaseTests.cs index 8437ef91e..600f1824b 100644 --- a/GsaGHTests/3_Components/4_Analysis/CreateAnalysisCaseTests.cs +++ b/GsaGHTests/3_Components/4_Analysis/CreateAnalysisCaseTests.cs @@ -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); } } } diff --git a/GsaGHTests/3_Components/4_Analysis/CreateAnalysisTaskTests.cs b/GsaGHTests/3_Components/4_Analysis/CreateAnalysisTaskTests.cs index c3bfb8dcf..8468376c8 100644 --- a/GsaGHTests/3_Components/4_Analysis/CreateAnalysisTaskTests.cs +++ b/GsaGHTests/3_Components/4_Analysis/CreateAnalysisTaskTests.cs @@ -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] diff --git a/GsaGHTests/3_Components/Obsolete/CreateAnalysisTaskTests_OBSOLETE.cs b/GsaGHTests/3_Components/Obsolete/CreateAnalysisTaskTests_OBSOLETE.cs index 0ba5fd841..5015d2a48 100644 --- a/GsaGHTests/3_Components/Obsolete/CreateAnalysisTaskTests_OBSOLETE.cs +++ b/GsaGHTests/3_Components/Obsolete/CreateAnalysisTaskTests_OBSOLETE.cs @@ -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); } } }