public void WhereTest() { using (var container = new RhetosTestContainer()) { var repository = container.Resolve <Common.DomRepository>(); repository.TestPolymorphic.DeactivatableEntity.Delete(repository.TestPolymorphic.DeactivatableEntity.Query()); Assert.AreEqual("", TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords.Query(), item => item.Name)); var d1 = new TestPolymorphic.DeactivatableEntity { Active = true, Name = "d1" }; var d2 = new TestPolymorphic.DeactivatableEntity { Active = true, Name = "d2" }; var d3 = new TestPolymorphic.DeactivatableEntity { Active = false, Name = "d3" }; var d5 = new TestPolymorphic.DeactivatableEntity { Active = true, Name = "xd5" }; var d6 = new TestPolymorphic.DeactivatableEntity { Active = true, Name = "xd6" }; var d7 = new TestPolymorphic.DeactivatableEntity { Active = true, Name = "d7" }; repository.TestPolymorphic.DeactivatableEntity.Insert(new[] { d1, d2, d3, d5, d6, d7 }); Assert.AreEqual("d1, d2, d7", TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords.Query(), item => item.Name)); Assert.AreEqual( TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords.Query().Select(item => item.ID)), TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords_Materialized.Query().Select(item => item.ID))); d2.Active = false; d3.Active = true; var d4 = new TestPolymorphic.DeactivatableEntity { Active = true, Name = "d4" }; d6.Name = "d6"; d7.Name = "xd7"; repository.TestPolymorphic.DeactivatableEntity.Save(new[] { d4 }, new[] { d2, d3, d6, d7 }, new[] { d1 }); Assert.AreEqual("d3, d4, d6", TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords.Query(), item => item.Name)); Assert.AreEqual( TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords.Query().Select(item => item.ID)), TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords_Materialized.Query().Select(item => item.ID))); } }
public void WhereTest() { using (var container = new RhetosTestContainer()) { var repository = container.Resolve<Common.DomRepository>(); repository.TestPolymorphic.DeactivatableEntity.Delete(repository.TestPolymorphic.DeactivatableEntity.All()); Assert.AreEqual("", TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords.Query(), item => item.Name)); var d1 = new TestPolymorphic.DeactivatableEntity { Active = true, Name = "d1" }; var d2 = new TestPolymorphic.DeactivatableEntity { Active = true, Name = "d2" }; var d3 = new TestPolymorphic.DeactivatableEntity { Active = false, Name = "d3" }; var d5 = new TestPolymorphic.DeactivatableEntity { Active = true, Name = "xd5" }; var d6 = new TestPolymorphic.DeactivatableEntity { Active = true, Name = "xd6" }; var d7 = new TestPolymorphic.DeactivatableEntity { Active = true, Name = "d7" }; repository.TestPolymorphic.DeactivatableEntity.Insert(new[] { d1, d2, d3, d5, d6, d7 }); Assert.AreEqual("d1, d2, d7", TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords.Query(), item => item.Name)); Assert.AreEqual( TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords.Query().Select(item => item.ID)), TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords_Materialized.Query().Select(item => item.ID))); d2.Active = false; d3.Active = true; var d4 = new TestPolymorphic.DeactivatableEntity { Active = true, Name = "d4" }; d6.Name = "d6"; d7.Name = "xd7"; repository.TestPolymorphic.DeactivatableEntity.Save(new[] { d4 }, new[] { d2, d3, d6, d7 }, new[] { d1 }); Assert.AreEqual("d3, d4, d6", TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords.Query(), item => item.Name)); Assert.AreEqual( TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords.Query().Select(item => item.ID)), TestUtility.DumpSorted(repository.TestPolymorphic.ActiveRecords_Materialized.Query().Select(item => item.ID))); } }