public void PageCount() { var TempGuid = Guid.NewGuid(); var TestObject = new Utilities.ORM.Manager.Session(); for (int x = 0; x < 100; ++x) { var TempObject = new TestClass(); TempObject.BoolReference = true; TempObject.ByteArrayReference = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; TempObject.ByteReference = 12; TempObject.CharReference = 'v'; TempObject.DecimalReference = 1.4213m; TempObject.DoubleReference = 1.32645d; TempObject.EnumReference = TestEnum.Value2; TempObject.FloatReference = 1234.5f; TempObject.GuidReference = TempGuid; TempObject.IntReference = 145145; TempObject.LongReference = 763421; TempObject.NullStringReference = null; TempObject.ShortReference = 5423; TempObject.StringReference = "agsdpghasdg"; TestObject.Save <TestClass, int>(TempObject); } Assert.Equal(4, TestObject.PageCount <TestClass>()); }
public void Delete() { Guid TempGuid = Guid.NewGuid(); var TestObject = new Utilities.ORM.Manager.Session(); for (int x = 0; x < 100; ++x) { var TempObject = new TestClass2(); TempObject.BoolReference = true; TempObject.ByteArrayReference = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; TempObject.ByteReference = 12; TempObject.CharReference = 'v'; TempObject.DecimalReference = 1.4213m; TempObject.DoubleReference = 1.32645d; TempObject.EnumReference = TestEnum.Value2; TempObject.FloatReference = 1234.5f; TempObject.GuidReference = TempGuid; TempObject.IntReference = 145145; TempObject.LongReference = 763421; TempObject.NullStringReference = null; TempObject.ShortReference = 5423; TempObject.StringReference = "agsdpghasdg"; TestObject.Save <ITestInterface, int>(TempObject); } TestObject.Delete(TestObject.Any <ITestInterface>()); IEnumerable <ITestInterface> ItemList = TestObject.All <ITestInterface>(); Assert.Equal(99, ItemList.Count()); }
public void AnyByID() { var TempGuid = Guid.NewGuid(); var TestObject = new Utilities.ORM.Manager.Session(); for (int x = 0; x < 100; ++x) { var TempObject = new TestClass(); TempObject.BoolReference = true; TempObject.ByteArrayReference = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; TempObject.ByteReference = 12; TempObject.CharReference = 'v'; TempObject.DecimalReference = 1.4213m; TempObject.DoubleReference = 1.32645d; TempObject.EnumReference = TestEnum.Value2; TempObject.FloatReference = 1234.5f; TempObject.GuidReference = TempGuid; TempObject.IntReference = 145145; TempObject.LongReference = 763421; TempObject.NullStringReference = null; TempObject.ShortReference = 5423; TempObject.StringReference = "agsdpghasdg"; TestObject.Save <TestClass, int>(TempObject); } var Item = TestObject.Any <TestClass, int>(10); Assert.Equal(10, Item.ID); Assert.Equal(true, Item.BoolReference); Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, Item.ByteArrayReference); Assert.Equal(12, Item.ByteReference); Assert.Equal('v', Item.CharReference); Assert.Equal(1.4213m, Item.DecimalReference); Assert.Equal(1.32645d, Item.DoubleReference); Assert.Equal(TestEnum.Value2, Item.EnumReference); Assert.Equal(1234.5f, Item.FloatReference); Assert.Equal(TempGuid, Item.GuidReference); Assert.Equal(145145, Item.IntReference); Assert.Equal(763421, Item.LongReference); Assert.Equal(null, Item.NullStringReference); Assert.Equal(5423, Item.ShortReference); Assert.Equal("agsdpghasdg", Item.StringReference); Item = TestObject.Any <TestClass, int>(20); Assert.Equal(20, Item.ID); Assert.Equal(true, Item.BoolReference); Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, Item.ByteArrayReference); Assert.Equal(12, Item.ByteReference); Assert.Equal('v', Item.CharReference); Assert.Equal(1.4213m, Item.DecimalReference); Assert.Equal(1.32645d, Item.DoubleReference); Assert.Equal(TestEnum.Value2, Item.EnumReference); Assert.Equal(1234.5f, Item.FloatReference); Assert.Equal(TempGuid, Item.GuidReference); Assert.Equal(145145, Item.IntReference); Assert.Equal(763421, Item.LongReference); Assert.Equal(null, Item.NullStringReference); Assert.Equal(5423, Item.ShortReference); Assert.Equal("agsdpghasdg", Item.StringReference); }
public void All() { Guid TempGuid = Guid.NewGuid(); var TestObject = new Utilities.ORM.Manager.Session(); for (int x = 0; x < 100; ++x) { var TempObject = new TestClass2(); TempObject.BoolReference = true; TempObject.ByteArrayReference = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; TempObject.ByteReference = 12; TempObject.CharReference = 'v'; TempObject.DecimalReference = 1.4213m; TempObject.DoubleReference = 1.32645d; TempObject.EnumReference = TestEnum.Value2; TempObject.FloatReference = 1234.5f; TempObject.GuidReference = TempGuid; TempObject.IntReference = 145145; TempObject.LongReference = 763421; TempObject.NullStringReference = null; TempObject.ShortReference = 5423; TempObject.StringReference = "agsdpghasdg"; TestObject.Save <TestAbstractClass, int>(TempObject); } IEnumerable <TestAbstractClass> ItemList = TestObject.All <TestAbstractClass>(); Assert.Equal(100, ItemList.Count()); foreach (TestAbstractClass Item in ItemList) { Assert.Equal(true, Item.BoolReference); Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, Item.ByteArrayReference); Assert.Equal(12, Item.ByteReference); Assert.Equal('v', Item.CharReference); Assert.Equal(1.4213m, Item.DecimalReference); Assert.Equal(1.32645d, Item.DoubleReference); Assert.Equal(TestEnum.Value2, Item.EnumReference); Assert.Equal(1234.5f, Item.FloatReference); Assert.Equal(TempGuid, Item.GuidReference); Assert.Equal(145145, Item.IntReference); Assert.Equal(763421, Item.LongReference); Assert.Equal(null, Item.NullStringReference); Assert.Equal(5423, Item.ShortReference); Assert.Equal("agsdpghasdg", Item.StringReference); } }
public void UpdateCascade() { var TempGuid = Guid.NewGuid(); var TestObject = new Utilities.ORM.Manager.Session(); var TempObject = new TestClass(); TempObject.BoolReference = true; TempObject.ByteArrayReference = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; TempObject.ByteReference = 12; TempObject.CharReference = 'v'; TempObject.DecimalReference = 1.4213m; TempObject.DoubleReference = 1.32645d; TempObject.EnumReference = TestEnum.Value2; TempObject.FloatReference = 1234.5f; TempObject.GuidReference = TempGuid; TempObject.IntReference = 145145; TempObject.LongReference = 763421; TempObject.ManyToManyIEnumerable = new TestClass[] { new TestClass(), new TestClass() }; TempObject.ManyToManyList = new TestClass[] { new TestClass(), new TestClass(), new TestClass() }.ToList(); TempObject.ManyToOneIEnumerable = new TestClass[] { new TestClass(), new TestClass(), new TestClass() }; TempObject.ManyToOneItem = new TestClass(); TempObject.ManyToOneList = new TestClass[] { new TestClass(), new TestClass(), new TestClass() }.ToList(); TempObject.ManyToOneIList = new TestClass[] { new TestClass(), new TestClass(), new TestClass() }.ToList(); TempObject.ManyToManyIList = new TestClass[] { new TestClass(), new TestClass() }.ToList(); TempObject.ManyToOneICollection = new TestClass[] { new TestClass(), new TestClass(), new TestClass(), new TestClass() }.ToList(); TempObject.ManyToManyICollection = new TestClass[] { new TestClass() }.ToList(); TempObject.Map = new TestClass(); TempObject.NullStringReference = null; TempObject.ShortReference = 5423; TempObject.StringReference = "agsdpghasdg"; TestObject.Save <TestClass, int>(TempObject); Assert.Equal(true, TempObject.BoolReference); Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, TempObject.ByteArrayReference); Assert.Equal(12, TempObject.ByteReference); Assert.Equal('v', TempObject.CharReference); Assert.Equal(1.4213m, TempObject.DecimalReference); Assert.Equal(1.32645d, TempObject.DoubleReference); Assert.Equal(TestEnum.Value2, TempObject.EnumReference); Assert.Equal(1234.5f, TempObject.FloatReference); Assert.Equal(TempGuid, TempObject.GuidReference); Assert.Equal(145145, TempObject.IntReference); Assert.Equal(763421, TempObject.LongReference); Assert.Equal(2, TempObject.ManyToManyIEnumerable.Count()); Assert.Equal(3, TempObject.ManyToManyList.Count); Assert.Equal(3, TempObject.ManyToOneIEnumerable.Count()); Assert.NotNull(TempObject.ManyToOneItem); Assert.Equal(3, TempObject.ManyToOneList.Count); Assert.Equal(3, TempObject.ManyToOneIList.Count); Assert.Equal(2, TempObject.ManyToManyIList.Count); Assert.Equal(4, TempObject.ManyToOneICollection.Count); Assert.Equal(1, TempObject.ManyToManyICollection.Count); Assert.NotNull(TempObject.Map); Assert.Equal(null, TempObject.NullStringReference); Assert.Equal(5423, TempObject.ShortReference); Assert.Equal("agsdpghasdg", TempObject.StringReference); var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(new Utilities.ORM.Manager.SourceProvider.Manager(Utilities.IoC.Manager.Bootstrapper.ResolveAll <IDatabase>()).GetSource("Data Source=localhost;Initial Catalog=SessionTestDatabase;Integrated Security=SSPI;Pooling=false")); var Items = Temp.AddCommand(null, null, CommandType.Text, "SELECT * FROM TestClass_").Execute().First(); TestClass Item = Items.FirstOrDefault(x => x.BoolReference_); ((IORMObject)Item).Session0 = new Utilities.ORM.Manager.Session(); Assert.Equal(true, Item.BoolReference); Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, Item.ByteArrayReference); Assert.Equal(12, Item.ByteReference); Assert.Equal('v', Item.CharReference); Assert.Equal(1.4213m, Item.DecimalReference); Assert.Equal(1.32645d, Item.DoubleReference); Assert.Equal(TestEnum.Value2, Item.EnumReference); Assert.Equal(1234.5f, Item.FloatReference); Assert.Equal(TempGuid, Item.GuidReference); Assert.Equal(145145, Item.IntReference); Assert.Equal(763421, Item.LongReference); Assert.Equal(2, Item.ManyToManyIEnumerable.Count()); Assert.Equal(3, Item.ManyToManyList.Count); Assert.Equal(3, Item.ManyToOneIEnumerable.Count()); Assert.NotNull(Item.ManyToOneItem); Assert.Equal(3, Item.ManyToOneList.Count); Assert.NotNull(Item.Map); Assert.Equal(null, Item.NullStringReference); Assert.Equal(5423, Item.ShortReference); Assert.Equal("agsdpghasdg", Item.StringReference); Item.Map = new TestClass { FloatReference = 10f }; Item.ManyToManyIEnumerable.First().FloatReference = 11f; Item.ManyToManyList.Add(new TestClass { FloatReference = 12f }); Item.ManyToOneIEnumerable.First().FloatReference = 13f; Item.ManyToOneItem.FloatReference = 14f; Item.ManyToOneList = new TestClass[] { new TestClass(), new TestClass() }.ToList(); Item.ManyToManyIList.Add(new TestClass { FloatReference = 15f }); Item.ManyToOneIList.Add(new TestClass { FloatReference = 16f }); Item.ManyToManyICollection.Add(new TestClass { FloatReference = 17f }); Item.ManyToOneICollection.Add(new TestClass { FloatReference = 18f }); TestObject.Save <TestClass, int>(Item); Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(new Utilities.ORM.Manager.SourceProvider.Manager(Utilities.IoC.Manager.Bootstrapper.ResolveAll <IDatabase>()).GetSource("Data Source=localhost;Initial Catalog=SessionTestDatabase;Integrated Security=SSPI;Pooling=false")); Items = Temp.AddCommand(null, null, CommandType.Text, "SELECT * FROM TestClass_").Execute().First(); Item = Items.FirstOrDefault(x => x.BoolReference_); ((IORMObject)Item).Session0 = new Utilities.ORM.Manager.Session(); Assert.Equal(10, Item.Map.FloatReference); Assert.Equal(11f, Item.ManyToManyIEnumerable.First().FloatReference); Assert.Equal(12f, Item.ManyToManyList.Last().FloatReference); Assert.Equal(13f, Item.ManyToOneIEnumerable.First().FloatReference); Assert.Equal(14f, Item.ManyToOneItem.FloatReference); Assert.Equal(15f, Item.ManyToManyIList.Last().FloatReference); Assert.Equal(16f, Item.ManyToOneIList.Last().FloatReference); Assert.Equal(17f, Item.ManyToManyICollection.Last().FloatReference); Assert.Equal(18f, Item.ManyToOneICollection.Last().FloatReference); Assert.Equal(2, Item.ManyToOneList.Count); }
public void Update() { Guid TempGuid = Guid.NewGuid(); var TestObject = new Utilities.ORM.Manager.Session(); var TempObject = new TestClass2(); TempObject.BoolReference = true; TempObject.ByteArrayReference = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; TempObject.ByteReference = 12; TempObject.CharReference = 'v'; TempObject.DecimalReference = 1.4213m; TempObject.DoubleReference = 1.32645d; TempObject.EnumReference = TestEnum.Value2; TempObject.FloatReference = 1234.5f; TempObject.GuidReference = TempGuid; TempObject.IntReference = 145145; TempObject.LongReference = 763421; TempObject.ManyToManyIEnumerable = new TestClass2[] { new TestClass2(), new TestClass2() }; TempObject.ManyToManyList = new TestAbstractClass[] { new TestClass2(), new TestClass2(), new TestClass2() }.ToList(); TempObject.ManyToOneIEnumerable = new TestClass2[] { new TestClass2(), new TestClass2(), new TestClass2() }; TempObject.ManyToOneItem = new TestClass2(); TempObject.ManyToOneList = new TestAbstractClass[] { new TestClass2(), new TestClass2(), new TestClass2() }.ToList(); TempObject.Map = new TestClass2(); TempObject.NullStringReference = null; TempObject.ShortReference = 5423; TempObject.StringReference = "agsdpghasdg"; TestObject.Save <TestAbstractClass, int>(TempObject); Assert.Equal(true, TempObject.BoolReference); Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, TempObject.ByteArrayReference); Assert.Equal(12, TempObject.ByteReference); Assert.Equal('v', TempObject.CharReference); Assert.Equal(1.4213m, TempObject.DecimalReference); Assert.Equal(1.32645d, TempObject.DoubleReference); Assert.Equal(TestEnum.Value2, TempObject.EnumReference); Assert.Equal(1234.5f, TempObject.FloatReference); Assert.Equal(TempGuid, TempObject.GuidReference); Assert.Equal(145145, TempObject.IntReference); Assert.Equal(763421, TempObject.LongReference); Assert.Equal(2, TempObject.ManyToManyIEnumerable.Count()); Assert.Equal(3, TempObject.ManyToManyList.Count); Assert.Equal(3, TempObject.ManyToOneIEnumerable.Count()); Assert.NotNull(TempObject.ManyToOneItem); Assert.Equal(3, TempObject.ManyToOneList.Count); Assert.NotNull(TempObject.Map); Assert.Equal(null, TempObject.NullStringReference); Assert.Equal(5423, TempObject.ShortReference); Assert.Equal("agsdpghasdg", TempObject.StringReference); var Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(new Utilities.ORM.Manager.SourceProvider.Manager(Utilities.IoC.Manager.Bootstrapper.ResolveAll <IDatabase>()).GetSource("Data Source=localhost;Initial Catalog=SessionWithAbstractClassTestDatabase;Integrated Security=SSPI;Pooling=false")); IList <dynamic> Items = Temp.AddCommand(null, null, CommandType.Text, "SELECT * FROM TestAbstractClass_").Execute().First(); TestAbstractClass Item = Items.FirstOrDefault(x => x.BoolReference_); ((IORMObject)Item).Session0 = new Utilities.ORM.Manager.Session(); Assert.Equal(true, Item.BoolReference); Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, Item.ByteArrayReference); Assert.Equal(12, Item.ByteReference); Assert.Equal('v', Item.CharReference); Assert.Equal(1.4213m, Item.DecimalReference); Assert.Equal(1.32645d, Item.DoubleReference); Assert.Equal(TestEnum.Value2, Item.EnumReference); Assert.Equal(1234.5f, Item.FloatReference); Assert.Equal(TempGuid, Item.GuidReference); Assert.Equal(145145, Item.IntReference); Assert.Equal(763421, Item.LongReference); Assert.Equal(2, Item.ManyToManyIEnumerable.Count()); Assert.Equal(3, Item.ManyToManyList.Count); Assert.Equal(3, Item.ManyToOneIEnumerable.Count()); Assert.NotNull(Item.ManyToOneItem); Assert.Equal(3, Item.ManyToOneList.Count); Assert.NotNull(Item.Map); Assert.Equal(null, Item.NullStringReference); Assert.Equal(5423, Item.ShortReference); Assert.Equal("agsdpghasdg", Item.StringReference); Item.ByteArrayReference = new byte[] { 11, 12, 13, 14, 15, 16, 17, 18, 19, 110 }; Item.ByteReference = 121; Item.CharReference = 'V'; Item.DecimalReference = 11.4213m; Item.DoubleReference = 11.32645d; Item.EnumReference = TestEnum.Value3; Item.FloatReference = 14.5f; Item.IntReference = 1451445; Item.LongReference = 7634121; Item.ShortReference = 43; Item.StringReference = "Something"; TestObject.Save <TestAbstractClass, int>(Item); Temp = new Utilities.ORM.Manager.QueryProvider.Default.DatabaseBatch(new Utilities.ORM.Manager.SourceProvider.Manager(Utilities.IoC.Manager.Bootstrapper.ResolveAll <IDatabase>()).GetSource("Data Source=localhost;Initial Catalog=SessionWithAbstractClassTestDatabase;Integrated Security=SSPI;Pooling=false")); Items = Temp.AddCommand(null, null, CommandType.Text, "SELECT * FROM TestAbstractClass_").Execute().First(); Item = Items.FirstOrDefault(x => x.BoolReference_); ((IORMObject)Item).Session0 = new Utilities.ORM.Manager.Session(); Assert.Equal(true, Item.BoolReference); Assert.Equal(new byte[] { 11, 12, 13, 14, 15, 16, 17, 18, 19, 110 }, Item.ByteArrayReference); Assert.Equal(121, Item.ByteReference); Assert.Equal('V', Item.CharReference); Assert.Equal(11.4213m, Item.DecimalReference); Assert.Equal(11.32645d, Item.DoubleReference); Assert.Equal(TestEnum.Value3, Item.EnumReference); Assert.Equal(14.5f, Item.FloatReference); Assert.Equal(TempGuid, Item.GuidReference); Assert.Equal(1451445, Item.IntReference); Assert.Equal(7634121, Item.LongReference); Assert.Equal(2, Item.ManyToManyIEnumerable.Count()); Assert.Equal(3, Item.ManyToManyList.Count); Assert.Equal(3, Item.ManyToOneIEnumerable.Count()); Assert.NotNull(Item.ManyToOneItem); Assert.Equal(3, Item.ManyToOneList.Count); Assert.NotNull(Item.Map); Assert.Equal(null, Item.NullStringReference); Assert.Equal(43, Item.ShortReference); Assert.Equal("Something", Item.StringReference); }