diff --git a/.gitignore b/.gitignore
index 9217bf3..988b449 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,8 @@
/.vs
/.venv
packages
+bin/
+obj/
AdSecGH/bin
AdSecGH/obj
AdSecGHConverters/bin
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index f63b4ef..d3433f5 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -6,7 +6,7 @@ repos:
- id: dotnet-build
name: Build
- entry: msbuild /p:AppxBundlePlatforms="x64" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /m /nr:false
+ entry: msbuild /p:AppxBundlePlatforms="x64" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /m /nr:false AdSecGH.sln
language: system
pass_filenames: false
stages: [pre-push]
diff --git a/AdSecCore.sln b/AdSecCore.sln
new file mode 100644
index 0000000..3b37bdf
--- /dev/null
+++ b/AdSecCore.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdSecCore", "AdSecCore\AdSecCore.csproj", "{2A3194AF-5B84-47DF-8E36-6819C2CF6E97}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdSecCoreTests", "AdSecCoreTests\AdSecCoreTests.csproj", "{2407A2E8-B608-454F-A6A9-EABDFFFF48FD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2A3194AF-5B84-47DF-8E36-6819C2CF6E97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2A3194AF-5B84-47DF-8E36-6819C2CF6E97}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2A3194AF-5B84-47DF-8E36-6819C2CF6E97}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2A3194AF-5B84-47DF-8E36-6819C2CF6E97}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2407A2E8-B608-454F-A6A9-EABDFFFF48FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2407A2E8-B608-454F-A6A9-EABDFFFF48FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2407A2E8-B608-454F-A6A9-EABDFFFF48FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2407A2E8-B608-454F-A6A9-EABDFFFF48FD}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/AdSecCore.sln.DotSettings.user b/AdSecCore.sln.DotSettings.user
new file mode 100644
index 0000000..45ee6b9
--- /dev/null
+++ b/AdSecCore.sln.DotSettings.user
@@ -0,0 +1,4 @@
+
+ <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
+ <Solution />
+</SessionState>
diff --git a/AdSecCore/AdSecCore.csproj b/AdSecCore/AdSecCore.csproj
new file mode 100644
index 0000000..138b136
--- /dev/null
+++ b/AdSecCore/AdSecCore.csproj
@@ -0,0 +1,9 @@
+
+
+
+ disable
+ disable
+ net48;net7.0
+
+
+
diff --git a/AdSecCore/DoubleComparer.cs b/AdSecCore/DoubleComparer.cs
new file mode 100644
index 0000000..02ecf02
--- /dev/null
+++ b/AdSecCore/DoubleComparer.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+
+namespace AdSecGHCore.Helpers {
+ public class DoubleComparer : IEqualityComparer {
+ private readonly double _epsilon = 0.01; //default accuracy in %
+ private readonly bool _margin;
+
+ public DoubleComparer(double epsilon = 0.01, bool useEpsilonAsMargin = false) {
+ _epsilon = epsilon;
+ _margin = useEpsilonAsMargin;
+ }
+
+ public bool Equals(double x, double y) {
+ x = Math.Round(x, 6);
+ y = Math.Round(y, 6);
+
+ if (x == y) {
+ return true;
+ }
+
+ if (_margin) {
+ if (Math.Abs(x - y) < _epsilon) {
+ return true;
+ }
+ } else {
+ double error = Math.Abs(x - y) / (x + y) * 0.5;
+ return error < _epsilon;
+ }
+
+ return false;
+ }
+
+ public int GetHashCode(double obj) {
+ return obj.GetHashCode();
+ }
+ }
+}
diff --git a/AdSecCore/Result.cs b/AdSecCore/Result.cs
new file mode 100644
index 0000000..5526ae1
--- /dev/null
+++ b/AdSecCore/Result.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+
+namespace AdSecGHCore.Helpers {
+
+ internal class Result {
+
+ internal static double RoundToSignificantDigits(double d, int digits) {
+ if (d == 0.0) {
+ return 0.0;
+ }
+
+ double leftSideNumbers = Math.Floor(Math.Log10(Math.Abs(d))) + 1;
+ double scale = Math.Pow(10, leftSideNumbers);
+ double result = scale * Math.Round(d / scale, digits, MidpointRounding.AwayFromZero);
+
+ // Clean possible precision error.
+ if ((int)leftSideNumbers >= digits) {
+ return Math.Round(result, 0, MidpointRounding.AwayFromZero);
+ }
+
+ if (Math.Abs(digits - (int)leftSideNumbers) > 15) {
+ return 0.0;
+ }
+
+ return Math.Round(result, digits - (int)leftSideNumbers, MidpointRounding.AwayFromZero);
+ }
+
+ internal static List SmartRounder(double max, double min) {
+ // find the biggest abs value of max and min
+ double val = Math.Max(Math.Abs(max), Math.Abs(min));
+
+ // round that with 4 significant digits
+ double scale = RoundToSignificantDigits(val, 4);
+
+ // list to hold output values
+ var roundedvals = new List();
+
+ // do max
+ if (max == 0) {
+ roundedvals.Add(0);
+ } else {
+ double tempmax = scale * Math.Round(max / scale, 4);
+ tempmax = Math.Ceiling(tempmax * 1000) / 1000;
+ roundedvals.Add(tempmax);
+ }
+
+ // do min
+ if (min == 0) {
+ roundedvals.Add(0);
+ } else {
+ double tempmin = scale * Math.Round(min / scale, 4);
+ tempmin = Math.Floor(tempmin * 1000) / 1000;
+ roundedvals.Add(tempmin);
+ }
+
+ return roundedvals;
+ }
+ }
+}
diff --git a/AdSecCoreTests/AdSecCoreTests.csproj b/AdSecCoreTests/AdSecCoreTests.csproj
new file mode 100644
index 0000000..04cd64a
--- /dev/null
+++ b/AdSecCoreTests/AdSecCoreTests.csproj
@@ -0,0 +1,31 @@
+
+
+
+ net7.0
+ enable
+ enable
+
+ false
+ true
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AdSecCoreTests/DoubleComparerTests.cs b/AdSecCoreTests/DoubleComparerTests.cs
new file mode 100644
index 0000000..5f43011
--- /dev/null
+++ b/AdSecCoreTests/DoubleComparerTests.cs
@@ -0,0 +1,16 @@
+using AdSecGHCore.Helpers;
+
+namespace AdSecCoreTests {
+ public class DoubleComparerTests {
+ [Fact]
+ public void ValuesDifferLessThanEpsilonShouldBeConsideredEqual() {
+ Assert.Equal(10.0, 10.01, new DoubleComparer());
+ }
+
+ [Fact]
+ public void ValuesLargerThanEpsilonShouldBeConsideredEqual() {
+ int epsilon = 1;
+ Assert.NotEqual(10.0, 10.0 + (epsilon * 2), new DoubleComparer(epsilon, true));
+ }
+ }
+}
diff --git a/AdSecGH.sln b/AdSecGH.sln
index e5231d2..2c81397 100644
--- a/AdSecGH.sln
+++ b/AdSecGH.sln
@@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdSecGHConverters", "AdSecG
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdSecGHConverterTests", "AdSecGHConverterTests\AdSecGHConverterTests.csproj", "{885C7D18-8B54-4430-A84B-8FD37CF7AD27}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdSecCore", "AdSecCore\AdSecCore.csproj", "{D7A31820-EC4F-42EC-863C-51BB3647A145}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdSecCoreTests", "AdSecCoreTests\AdSecCoreTests.csproj", "{DF259C79-A298-44B9-B702-573D4206A3C2}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -39,6 +43,14 @@ Global
{885C7D18-8B54-4430-A84B-8FD37CF7AD27}.Debug|x64.Build.0 = Debug|x64
{885C7D18-8B54-4430-A84B-8FD37CF7AD27}.Release|x64.ActiveCfg = Release|x64
{885C7D18-8B54-4430-A84B-8FD37CF7AD27}.Release|x64.Build.0 = Release|x64
+ {D7A31820-EC4F-42EC-863C-51BB3647A145}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {D7A31820-EC4F-42EC-863C-51BB3647A145}.Debug|x64.Build.0 = Debug|Any CPU
+ {D7A31820-EC4F-42EC-863C-51BB3647A145}.Release|x64.ActiveCfg = Release|Any CPU
+ {D7A31820-EC4F-42EC-863C-51BB3647A145}.Release|x64.Build.0 = Release|Any CPU
+ {DF259C79-A298-44B9-B702-573D4206A3C2}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {DF259C79-A298-44B9-B702-573D4206A3C2}.Debug|x64.Build.0 = Debug|Any CPU
+ {DF259C79-A298-44B9-B702-573D4206A3C2}.Release|x64.ActiveCfg = Release|Any CPU
+ {DF259C79-A298-44B9-B702-573D4206A3C2}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/AdSecGH.sln.DotSettings.user b/AdSecGH.sln.DotSettings.user
new file mode 100644
index 0000000..edce023
--- /dev/null
+++ b/AdSecGH.sln.DotSettings.user
@@ -0,0 +1,4 @@
+
+ <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
+ <Solution />
+</SessionState>
diff --git a/AdSecGH/AdSecGH.csproj b/AdSecGH/AdSecGH.csproj
index 50f792c..d3176bd 100644
--- a/AdSecGH/AdSecGH.csproj
+++ b/AdSecGH/AdSecGH.csproj
@@ -84,6 +84,9 @@
+
+
+
C:\Program Files\Rhino 7\System\Rhino.exe
diff --git a/AdSecGH/Helpers/Result.cs b/AdSecGH/Helpers/Result.cs
index ba3e5f6..4ac9bf8 100644
--- a/AdSecGH/Helpers/Result.cs
+++ b/AdSecGH/Helpers/Result.cs
@@ -1,94 +1,94 @@
-using System;
-using System.Collections.Generic;
-
-namespace AdSecGH.Helpers {
- public class DoubleComparer : IEqualityComparer {
- private double _epsilon = 0.01; //default accuracy in %
- private bool _margin = false;
-
- public DoubleComparer(double epsilon = 0.01, bool useEpsilonAsMargin = false) {
- _epsilon = epsilon;
- _margin = useEpsilonAsMargin;
- }
-
- public bool Equals(double x, double y) {
- x = Math.Round(x, 6);
- y = Math.Round(y, 6);
-
- if (x == y) {
- return true;
- }
-
- if (_margin) {
- if (Math.Abs(x - y) < _epsilon) {
- return true;
- }
- } else {
- double error = Math.Abs(x - y) / (x + y) * 0.5;
- return error < _epsilon;
- }
-
- return false;
- }
-
- public int GetHashCode(double obj) {
- return obj.GetHashCode();
- }
-
- }
-
- internal class Result {
-
- internal static double RoundToSignificantDigits(double d, int digits) {
- if (d == 0.0) {
- return 0.0;
- } else {
- double leftSideNumbers = Math.Floor(Math.Log10(Math.Abs(d))) + 1;
- double scale = Math.Pow(10, leftSideNumbers);
- double result = scale * Math.Round(d / scale, digits, MidpointRounding.AwayFromZero);
-
- // Clean possible precision error.
- if ((int)leftSideNumbers >= digits) {
- return Math.Round(result, 0, MidpointRounding.AwayFromZero);
- } else {
- if (Math.Abs(digits - (int)leftSideNumbers) > 15) {
- return 0.0;
- }
-
- return Math.Round(result, digits - (int)leftSideNumbers, MidpointRounding.AwayFromZero);
- }
- }
- }
-
- internal static List SmartRounder(double max, double min) {
- // find the biggest abs value of max and min
- double val = Math.Max(Math.Abs(max), Math.Abs(min));
-
- // round that with 4 significant digits
- double scale = RoundToSignificantDigits(val, 4);
-
- // list to hold output values
- var roundedvals = new List();
-
- // do max
- if (max == 0) {
- roundedvals.Add(0);
- } else {
- double tempmax = scale * Math.Round(max / scale, 4);
- tempmax = Math.Ceiling(tempmax * 1000) / 1000;
- roundedvals.Add(tempmax);
- }
-
- // do min
- if (min == 0) {
- roundedvals.Add(0);
- } else {
- double tempmin = scale * Math.Round(min / scale, 4);
- tempmin = Math.Floor(tempmin * 1000) / 1000;
- roundedvals.Add(tempmin);
- }
-
- return roundedvals;
- }
- }
-}
+// using System;
+// using System.Collections.Generic;
+//
+// namespace AdSecGH.Helpers {
+// public class DoubleComparer : IEqualityComparer {
+// private double _epsilon = 0.01; //default accuracy in %
+// private bool _margin = false;
+//
+// public DoubleComparer(double epsilon = 0.01, bool useEpsilonAsMargin = false) {
+// _epsilon = epsilon;
+// _margin = useEpsilonAsMargin;
+// }
+//
+// public bool Equals(double x, double y) {
+// x = Math.Round(x, 6);
+// y = Math.Round(y, 6);
+//
+// if (x == y) {
+// return true;
+// }
+//
+// if (_margin) {
+// if (Math.Abs(x - y) < _epsilon) {
+// return true;
+// }
+// } else {
+// double error = Math.Abs(x - y) / (x + y) * 0.5;
+// return error < _epsilon;
+// }
+//
+// return false;
+// }
+//
+// public int GetHashCode(double obj) {
+// return obj.GetHashCode();
+// }
+//
+// }
+//
+// internal class Result {
+//
+// internal static double RoundToSignificantDigits(double d, int digits) {
+// if (d == 0.0) {
+// return 0.0;
+// } else {
+// double leftSideNumbers = Math.Floor(Math.Log10(Math.Abs(d))) + 1;
+// double scale = Math.Pow(10, leftSideNumbers);
+// double result = scale * Math.Round(d / scale, digits, MidpointRounding.AwayFromZero);
+//
+// // Clean possible precision error.
+// if ((int)leftSideNumbers >= digits) {
+// return Math.Round(result, 0, MidpointRounding.AwayFromZero);
+// } else {
+// if (Math.Abs(digits - (int)leftSideNumbers) > 15) {
+// return 0.0;
+// }
+//
+// return Math.Round(result, digits - (int)leftSideNumbers, MidpointRounding.AwayFromZero);
+// }
+// }
+// }
+//
+// internal static List SmartRounder(double max, double min) {
+// // find the biggest abs value of max and min
+// double val = Math.Max(Math.Abs(max), Math.Abs(min));
+//
+// // round that with 4 significant digits
+// double scale = RoundToSignificantDigits(val, 4);
+//
+// // list to hold output values
+// var roundedvals = new List();
+//
+// // do max
+// if (max == 0) {
+// roundedvals.Add(0);
+// } else {
+// double tempmax = scale * Math.Round(max / scale, 4);
+// tempmax = Math.Ceiling(tempmax * 1000) / 1000;
+// roundedvals.Add(tempmax);
+// }
+//
+// // do min
+// if (min == 0) {
+// roundedvals.Add(0);
+// } else {
+// double tempmin = scale * Math.Round(min / scale, 4);
+// tempmin = Math.Floor(tempmin * 1000) / 1000;
+// roundedvals.Add(tempmin);
+// }
+//
+// return roundedvals;
+// }
+// }
+// }
diff --git a/AdSecGHTests/AdSecGHTests.csproj b/AdSecGHTests/AdSecGHTests.csproj
index 59a67be..badfb4d 100644
--- a/AdSecGHTests/AdSecGHTests.csproj
+++ b/AdSecGHTests/AdSecGHTests.csproj
@@ -3,12 +3,13 @@
net48
x64
x64
+ 8
-
-
-
-
+
+
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
@@ -20,7 +21,7 @@
-
+
@@ -28,10 +29,10 @@
-
+
-
+
diff --git a/AdSecGHTests/Components/1_Properties/CreateConcreteCrackCalculationParametersComponentTests.cs b/AdSecGHTests/Components/1_Properties/CreateConcreteCrackCalculationParametersComponentTests.cs
index ed635fc..80bc709 100644
--- a/AdSecGHTests/Components/1_Properties/CreateConcreteCrackCalculationParametersComponentTests.cs
+++ b/AdSecGHTests/Components/1_Properties/CreateConcreteCrackCalculationParametersComponentTests.cs
@@ -17,7 +17,7 @@ public static GH_OasysDropDownComponent ComponentMother() {
comp.SetSelected(0, 0); // change dropdown to ?
- ComponentTestHelper.SetInput(comp, 130, 0);
+ ComponentTestHelper.SetInput(comp, 130);
ComponentTestHelper.SetInput(comp, 1700, 1);
ComponentTestHelper.SetInput(comp, 1200, 2);
@@ -26,13 +26,13 @@ public static GH_OasysDropDownComponent ComponentMother() {
[Fact]
public void ChangeDropDownTest() {
- GH_OasysDropDownComponent comp = ComponentMother();
+ var comp = ComponentMother();
OasysDropDownComponentTestHelper.ChangeDropDownTest(comp);
}
[Fact]
public void CreateComponent() {
- GH_OasysDropDownComponent comp = ComponentMother();
+ var comp = ComponentMother();
comp.SetSelected(0, 0); // change dropdown to ?
var output = (AdSecConcreteCrackCalculationParametersGoo)ComponentTestHelper.GetOutput(comp);
//Assert.Equal(0, output.Value.StartPosition.Value);
@@ -61,7 +61,7 @@ public void CreateComponent() {
[Fact]
public void DeserializeTest() {
- GH_OasysDropDownComponent comp = ComponentMother();
+ var comp = ComponentMother();
OasysDropDownComponentTestHelper.DeserializeTest(comp);
}
}
diff --git a/AdSecGHTests/Helpers/AdSecFileTest.cs b/AdSecGHTests/Helpers/AdSecFileTest.cs
index 90543a8..59abad4 100644
--- a/AdSecGHTests/Helpers/AdSecFileTest.cs
+++ b/AdSecGHTests/Helpers/AdSecFileTest.cs
@@ -5,7 +5,6 @@
using AdSecGH;
using AdSecGH.Helpers;
-using AdSecGH.Parameters;
using Xunit;
@@ -26,7 +25,7 @@ public void GetDesignCode_ForExistingCodesInAdSecFile_Test() {
foreach (string key in AdSecFile.Codes.Keys) {
string json = CreateSampleJson(key);
- AdSecDesignCode code = AdSecFile.GetDesignCode(json);
+ var code = AdSecFile.GetDesignCode(json);
Assert.True(AdSecFile.Codes.ContainsValue(code.DesignCode));
Assert.True(AdSecFile.CodesStrings.ContainsValue(code.DesignCodeName.Replace(" ", "+")));
@@ -41,7 +40,7 @@ public void GetDesignCode_ForInvalidCode_Test() {
string json = CreateSampleJson("I'm invalid design code!");
- AdSecDesignCode code = AdSecFile.GetDesignCode(json);
+ var code = AdSecFile.GetDesignCode(json);
Assert.Null(code);
}
@@ -54,7 +53,7 @@ public void GetDesignCode_ForInvalidJson_Test() {
string json = CreateSampleJson(AdSecFile.Codes.Keys.FirstOrDefault(), false);
- AdSecDesignCode code = AdSecFile.GetDesignCode(json);
+ var code = AdSecFile.GetDesignCode(json);
Assert.Null(code);
}
diff --git a/AdSecGHTests/Helpers/Duplicates.cs b/AdSecGHTests/Helpers/Duplicates.cs
index cd414d7..365ea60 100644
--- a/AdSecGHTests/Helpers/Duplicates.cs
+++ b/AdSecGHTests/Helpers/Duplicates.cs
@@ -4,36 +4,118 @@
using System.Linq;
using System.Reflection;
+using AdSecGH.Components;
+
+using Grasshopper.Kernel;
+
+using OasysGH.Components;
+
using Xunit;
namespace AdSecGHTests.Helpers {
+
+ public static class ModFactory {
+ public static Type[] GetAllAssemblyTypes(string assemblyName = "AdSec.dll", string nameSpace = "") {
+ var assemblies = AppDomain.CurrentDomain.GetAssemblies();
+
+ foreach (var item in assemblies) {
+ Console.WriteLine(item);
+ var other = item.GetLoadedModules();
+ other.ToList().ForEach(m => Console.WriteLine(m));
+ }
+
+ var assembly = assemblies.FirstOrDefault(x => x.ManifestModule.Name.Equals(assemblyName)
+ || x.ManifestModule.ScopeName.Equals(assemblyName));
+
+ var classes = assembly.GetTypes();
+ if (nameSpace != string.Empty) {
+ classes = classes.Where(x => x.Namespace == nameSpace).ToArray();
+ }
+
+ return classes;
+ }
+
+ public static IEnumerable ImplementsInterface(this Type[] collection, Type[] interfaces) {
+ return collection.Where(x => x.IsClass && !x.IsAbstract && interfaces.All(y => y.IsAssignableFrom(x)));
+ }
+
+ public static IEnumerable GetAllInterfaceTypes(Type[] interfaces) {
+ var allAssemblyTypes = GetAllAssemblyTypes();
+ return allAssemblyTypes.ImplementsInterface(interfaces);
+ }
+
+ public static IEnumerable GetAllInterfaceTypes() {
+ return GetAllInterfaceTypes(new[] {
+ typeof(GH_Component),
+ typeof(GH_OasysComponent),
+ });
+ }
+
+ public static GH_Component[] CreateInstancesWithCreateInterface() {
+ var allInterfaceTypes = GetAllInterfaceTypes();
+ var components = allInterfaceTypes.Select(Activator.CreateInstance).Select(x => x as GH_Component).ToArray();
+ return components;
+ }
+ }
+
+ [Collection("GrasshopperFixture collection")]
+ public class DropToCanvasTests {
+ //[Fact]
+ //public void TestAllComponents() {
+ // var instances = ModFactory.CreateInstancesWithCreateInterface();
+ // foreach (var instance in instances) {
+ // Assert.NotNull(instance);
+ // }
+ //}
+
+ [Fact]
+ public void TestAllComponentsByType() {
+ // Get All Assemblies
+ var assemblies = AppDomain.CurrentDomain.GetAssemblies();
+ // Get The One for AdSecGH
+ var assembly = assemblies.FirstOrDefault(x => x.ManifestModule.Name.Equals("AdSecGH.dll")
+ || x.ManifestModule.ScopeName.Equals("AdSecGH.dll"));
+ // Get All Types matching GH_Component or GH_OasysDropdownComponent
+ var types = assembly.GetTypes().Where(x
+ => x.IsClass && !x.IsAbstract && typeof(GH_OasysDropDownComponent).IsAssignableFrom(x)
+ && x != typeof(CreateDesignCode)).ToArray();
+ foreach (var type in types) {
+ var instance = (GH_Component)Activator.CreateInstance(type);
+ instance.ExpireSolution(true);
+ Assert.True(instance.RuntimeMessages(GH_RuntimeMessageLevel.Error).Count == 0);
+ }
+ }
+ }
+
public class Duplicates {
public static bool AreEqual(object objA, object objB, bool excludeGuid = false) {
- if (!(excludeGuid && objA.Equals(typeof(System.Guid)))) {
+ if (!(excludeGuid && objA.Equals(typeof(Guid)))) {
Assert.Equal(objA.ToString(), objB.ToString());
}
- Type typeA = objA.GetType();
- Type typeB = objB.GetType();
+ var typeA = objA.GetType();
+ var typeB = objB.GetType();
- PropertyInfo[] propertyInfoA = typeA.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
- PropertyInfo[] propertyInfoB = typeB.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
+ var propertyInfoA = typeA.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
+ var propertyInfoB = typeB.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
for (int i = 0; i < propertyInfoA.Length; i++) {
- PropertyInfo propertyA = propertyInfoA[i];
- PropertyInfo propertyB = propertyInfoB[i];
+ var propertyA = propertyInfoA[i];
+ var propertyB = propertyInfoB[i];
if (!propertyA.CanWrite && !propertyB.CanWrite) {
continue;
- } else if (!propertyA.CanWrite || !propertyB.CanWrite) {
+ }
+
+ if (!propertyA.CanWrite || !propertyB.CanWrite) {
Assert.Equal(objA, objB);
}
object objPropertyValueA;
object objPropertyValueB;
- Type propertyTypeA = propertyA.PropertyType;
- Type propertyTypeB = propertyB.PropertyType;
+ var propertyTypeA = propertyA.PropertyType;
+ var propertyTypeB = propertyB.PropertyType;
try {
objPropertyValueA = propertyA.GetValue(objA, null);
@@ -45,6 +127,7 @@ public static bool AreEqual(object objA, object objB, bool excludeGuid = false)
propertyTypeA = objPropertyValueA.GetType();
}
}
+
if (propertyTypeB.IsInterface) {
if (objPropertyValueB != null) {
propertyTypeB = objPropertyValueB.GetType();
@@ -53,21 +136,24 @@ public static bool AreEqual(object objA, object objB, bool excludeGuid = false)
// check wether property is an enumerable
if (typeof(IEnumerable).IsAssignableFrom(propertyTypeA) && !typeof(string).IsAssignableFrom(propertyTypeA)) {
- if (typeof(IEnumerable).IsAssignableFrom(propertyTypeB) && !typeof(string).IsAssignableFrom(propertyTypeB)) {
+ if (typeof(IEnumerable).IsAssignableFrom(propertyTypeB)
+ && !typeof(string).IsAssignableFrom(propertyTypeB)) {
if (objPropertyValueA == null || objPropertyValueB == null) {
Assert.Equal(objPropertyValueA, objPropertyValueB);
} else {
- IEnumerable