public virtual async Task Polymorphism() { await entityRepo.TruncateCollection(); await collectionEntityRepo.TruncateCollection(); TestExtraEltEntity entity2 = TestHelper.GetEntity2(); await entityRepo.InsertOne(entity2); Assert.IsFalse(string.IsNullOrEmpty(entity2.Id)); var entity2_repo = await entityRepo.GetById(entity2.Id); //entity_repo.LookLikeEachOther(entity); AssertHelper.AreJsonEqual(entity2, entity2_repo, ErrorMsg: "Get of a TestExtraEltEntity instance from a TestEntity repo should return TestExtraEltEntity"); //Assert.AreEqual<TestEntity>(entity1, entity1_repo); var collectionTest = new CollectionTest(); collectionTest.PolymorphCollection.Add(entity2); // TestExtraEltEntity instance collectionTest.PolymorphCollection.Add(TestHelper.GetEntity1()); // TestEntity instance await collectionEntityRepo.InsertOne(collectionTest); var collectionTest_fromRepo = await collectionEntityRepo.GetById(collectionTest.Id); AssertHelper.AreJsonEqual(collectionTest, collectionTest_fromRepo, ErrorMsg: "Check if collection elements has the good type"); }
static void Main(string[] args) { // CollectionTest.TestUntypedArray(); // CollectionTest.TestTypedArray(); CollectionTest.TestDictionary(); // CollectionTest.TestStaticArray(); CollectionTest.TestHashSet(); CollectionTest.TestUntypedArray(); Console.ReadKey(); }
/// <summary> /// Init Set demo /// => Copy files in : C:\Users\abala\AppData\Roaming /// </summary> public virtual void GetAll() { entityRepo.TruncateCollection(); var entity1 = TestHelper.GetEntity1(); entityRepo.InsertOne(entity1); var entity2 = TestHelper.GetEntity2(); entityRepo.InsertOne(entity2); var entity3 = TestHelper.GetEntity3(); entityRepo.InsertOne(entity3); var entity4 = TestHelper.GetEntity4(); entityRepo.InsertOne(entity4); entityRepo.Delete(entity3.Id); var entitylist = entityRepo.GetAll(); Assert.AreEqual(3, entitylist.Count, "Invalide number. The expected result is " + entitylist.Count); foreach (var e in entitylist) { Assert.IsNotNull(e, "Entity returned should not be null"); } var collectionTest = new CollectionTest(); collectionTest.PolymorphCollection.Add(entity1); // TestExtraEltEntity instance var collectionTest2 = new CollectionTest(); collectionTest2.PolymorphCollection.Add(entity2); // TestExtraEltEntity instance collectionEntityRepo.InsertOne(collectionTest); collectionEntityRepo.InsertOne(collectionTest2); var entityCollectionlist = collectionEntityRepo.GetAll(); Assert.AreEqual(2, entityCollectionlist.Count, "Bad number of doc. We should not return entities of an other collection"); var entitylist2 = entityRepo.GetAll(); Assert.AreEqual(3, entitylist2.Count, "Bad number of doc. We should not return entities of an other collection"); collectionEntityRepo.TruncateCollection(); entitylist2 = entityRepo.GetAll(); Assert.AreEqual(3, entitylist2.Count, "Truncate of a collection should not affect other collections"); }
public void TestCollections() { var serializer = CreateSerializer(); ValueTypeTest _test = new ValueTypeTest(); _test.integer = 1337; _test.identifier = "vtTest"; ValueTypeTest _test2 = new ValueTypeTest(); _test2.integer = 123; _test2.identifier = "vtTest2"; ValueTypeTestNoRoot _test3 = new ValueTypeTestNoRoot(); _test3.integer = 1337; CollectionTest test = new CollectionTest(); test.test = new ValueTypeTestNoRoot[] { _test3 }; test.test2 = new ValueTypeTest[] { _test2, _test }.ToList(); test.test3 = new List <int>(); test.test3.Add(321); test.test3.Add(132); List <ISerializableRoot> roots = new List <ISerializableRoot>(); roots.Add(test); roots.Add(_test2); roots.Add(_test); string xml = serializer.Serialize(roots, out errors); FlushErrors(); Debug.Log(xml); roots.Clear(); serializer.Deserialize(new string[] { xml }, new string[] { "MEMORY" }, null, out roots, out errors); FlushErrors(); Assert.AreEqual(roots.Count, 3); Assert.AreEqual(test, roots[0]); Assert.AreEqual(1337, (roots[0] as CollectionTest).test2[1].integer); Assert.AreEqual(132, (roots[0] as CollectionTest).test3[1]); }
public static void Main(string[] args) { StreamWriter sw = null; LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("getter-setter-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); GetterSetterTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("getter-setter-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); GetterSetterTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("invoke-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); InvokeTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("invoke-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); InvokeTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("creation-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); CreationTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("creation-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); CreationTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("collection-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); CollectionTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("collection-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); CollectionTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("arithmetic-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); ArithmeticTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("arithmetic-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); ArithmeticTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("threading-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); ThreadingTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("threading-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); ThreadingTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("timing-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); TimingTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("timing-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); TimingTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("autoboxing-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); AutoboxingTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("autoboxing-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); AutoboxingTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("file-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); FileTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("file-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); FileTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("exception-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); ExceptionTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("exception-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); ExceptionTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("recursive-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); RecursiveTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("recursive-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); RecursiveTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("stringconcat-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); StringConcatTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("stringconcat-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); StringConcatTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("nestedloops-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); NestedLoopsTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("nestedloops-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); NestedLoopsTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("heap-sort-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); HeapSortTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("heap-sort-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); HeapSortTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("matrix-multiply-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); MatrixMultiplyTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("matrix-multiply-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); MatrixMultiplyTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("reflection-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); ReflectionTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("reflection-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); ReflectionTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("enum-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); EnumTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("enum-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); EnumTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("trigo-benchmark-csharp-firstinvoke.csv", FileMode.Create)); Console.SetOut(sw); TrigoTest.main(ARGS); sw.Close(); LaunchGcAndSleep(); sw = new StreamWriter(new FileStream("trigo-benchmark-csharp.csv", FileMode.Create)); Console.SetOut(sw); TrigoTest.main(ARGS); sw.Close(); //TODO NetworkInvoke.main(ARGS); }