Unit test extended by SubmodelElementCollection tests
diff --git a/sdks/dotnet/basyx-core/BaSyx.Core.Tests/ModelUnitTest.cs b/sdks/dotnet/basyx-core/BaSyx.Core.Tests/ModelUnitTest.cs
index f18017c..f498de9 100644
--- a/sdks/dotnet/basyx-core/BaSyx.Core.Tests/ModelUnitTest.cs
+++ b/sdks/dotnet/basyx-core/BaSyx.Core.Tests/ModelUnitTest.cs
@@ -7,6 +7,7 @@
using FluentAssertions.Equivalency;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Globalization;
+using System.Linq;
namespace BaSyx.Core.Tests
{
@@ -84,5 +85,72 @@
shell.Submodels["MyTestSubmodel"].SubmodelElements.Retrieve<Property<int>>("MySubmodelElementCollection/SubProp2").Entity.Should().BeEquivalentTo(GetProperty<int>("SubProp2", 2), opts => options);
shell.Submodels["MyTestSubmodel"].SubmodelElements.Retrieve<Property<int>>("MySubmodelElementCollection/MySubSubmodelElementCollection/SubSubProp2").Entity.Should().BeEquivalentTo(GetProperty<int>("SubSubProp2", 2), opts => options);
}
+
+ [TestMethod]
+ public void TestMethod3_SubmodelElementCollectionArray()
+ {
+ SubmodelElementCollection<int> smcInt = new SubmodelElementCollection<int>("MyIntCollection", new int[] { 1, 2, 3, 4, 5 });
+
+ int[] myArray = smcInt;
+ myArray.Sum().Should().Be(15);
+
+ SubmodelElementCollection smcInt2 = smcInt;
+
+ SubmodelElementCollection<int> smcInt3 = new SubmodelElementCollection<int>(smcInt2);
+ int[] myArray2 = smcInt3;
+ myArray2.Sum().Should().Be(15);
+ }
+
+ [TestMethod]
+ public void TestMethod4_SubmodelElementCollectionEntity()
+ {
+ MyTestClass testClass = new MyTestClass()
+ {
+ TestPropInt = 5,
+ TestPropBool = false,
+ TestPropString = "StringyString"
+ };
+
+ SubmodelElementCollectionOfEntity<MyTestClass> smc = new SubmodelElementCollectionOfEntity<MyTestClass>("MyTestClassInstance", testClass);
+ smc.Count.Should().Be(3);
+
+ smc["TestPropString"].As<IProperty>().ToObject<string>().Should().Be(testClass.TestPropString);
+ smc["TestPropInt"].As<IProperty>().ToObject<int>().Should().Be(testClass.TestPropInt);
+ smc["TestPropBool"].As<IProperty>().ToObject<bool>().Should().Be(testClass.TestPropBool);
+
+ smc.Value.TestPropString.Should().Be(testClass.TestPropString);
+ smc.Value.TestPropInt.Should().Be(testClass.TestPropInt);
+ smc.Value.TestPropBool.Should().Be(testClass.TestPropBool);
+
+ SubmodelElementCollection smc2 = new SubmodelElementCollection("MyTestSMC")
+ {
+ Value =
+ {
+ new Property<string>("PropString", "StringTheString"),
+ new Property<bool>("PropBool", true),
+ new Property<int>("PropInt", 8),
+ }
+ };
+
+
+ SubmodelElementCollectionOfEntity<MyTestClass2> smcEntity2 = new SubmodelElementCollectionOfEntity<MyTestClass2>(smc2);
+ smcEntity2.Value.PropString.Should().Be("StringTheString");
+ smcEntity2.Value.PropInt.Should().Be(8);
+ smcEntity2.Value.PropBool.Should().Be(true);
+ }
+ }
+
+ public class MyTestClass2
+ {
+ public string PropString { get; set; }
+ public int PropInt { get; set; }
+ public bool PropBool { get; set; }
+ }
+
+ public class MyTestClass
+ {
+ public string TestPropString { get; set; }
+ public int TestPropInt { get; set; }
+ public bool TestPropBool { get; set; }
}
}