예제 #1
0
        public void Disjunctive()
        {
            using (var container = new RhetosTestContainer())
            {
                var repository = container.Resolve <Common.DomRepository>();

                repository.TestPolymorphic.Disjunctive1.Delete(repository.TestPolymorphic.Disjunctive1.All());
                repository.TestPolymorphic.Disjunctive2.Delete(repository.TestPolymorphic.Disjunctive2.All());
                Assert.AreEqual(0, repository.TestPolymorphic.Disjunctive.All().Count());

                var d1 = new TestPolymorphic.Disjunctive1 {
                    ID = Guid.NewGuid(), Name = "abc"
                };
                repository.TestPolymorphic.Disjunctive1.Insert(new[] { d1 });

                var d2 = new TestPolymorphic.Disjunctive2 {
                    ID = Guid.NewGuid(), Days = 123
                };
                repository.TestPolymorphic.Disjunctive2.Insert(new[] { d2 });

                var all = repository.TestPolymorphic.Disjunctive.All();
                Assert.AreEqual(
                    TestUtility.DumpSorted(new[] { d1.ID, d2.ID }),
                    TestUtility.DumpSorted(all, item => item.ID));

                var browseReport = repository.TestPolymorphic.DisjunctiveBrowse.Query()
                                   .Select(item => item.Subtype + "-" + item.Disjunctive1.Name + "-" + item.Disjunctive2Days)
                                   .ToList();
                Assert.AreEqual(
                    "TestPolymorphic.Disjunctive1-abc-, TestPolymorphic.Disjunctive2--123",
                    TestUtility.DumpSorted(browseReport));
            }
        }
예제 #2
0
        public void Disjunctive()
        {
            foreach (bool useDatabaseNullSemantics in new[] { false, true })
            {
                using (var container = new RhetosTestContainer())
                {
                    container.SetUseDatabaseNullSemantics(useDatabaseNullSemantics);
                    var repository = container.Resolve <Common.DomRepository>();

                    repository.TestPolymorphic.Disjunctive1.Delete(repository.TestPolymorphic.Disjunctive1.Load());
                    repository.TestPolymorphic.Disjunctive2.Delete(repository.TestPolymorphic.Disjunctive2.Load());
                    Assert.AreEqual(0, repository.TestPolymorphic.Disjunctive.Load().Count());

                    var d1 = new TestPolymorphic.Disjunctive1 {
                        ID = Guid.NewGuid(), Name = "abc"
                    };
                    repository.TestPolymorphic.Disjunctive1.Insert(new[] { d1 });

                    var d2 = new TestPolymorphic.Disjunctive2 {
                        ID = Guid.NewGuid(), Days = 123
                    };
                    repository.TestPolymorphic.Disjunctive2.Insert(new[] { d2 });

                    var all = repository.TestPolymorphic.Disjunctive.Query();
                    Assert.AreEqual(
                        TestUtility.DumpSorted(new[] { d1.ID, d2.ID }),
                        TestUtility.DumpSorted(all, item => item.ID));

                    var browseReport = repository.TestPolymorphic.DisjunctiveBrowse.Query()
                                       .AsEnumerable()
                                       .Select(item => item.Subtype + "-" + item.Disjunctive1?.Name + "-" + item.Disjunctive2Days)
                                       .ToList();
                    Assert.AreEqual(
                        "TestPolymorphic.Disjunctive1-abc-, TestPolymorphic.Disjunctive2--123",
                        TestUtility.DumpSorted(browseReport));
                }
            }
        }
예제 #3
0
        public void Disjunctive()
        {
            using (var container = new RhetosTestContainer())
            {
                var repository = container.Resolve<Common.DomRepository>();

                repository.TestPolymorphic.Disjunctive1.Delete(repository.TestPolymorphic.Disjunctive1.Load());
                repository.TestPolymorphic.Disjunctive2.Delete(repository.TestPolymorphic.Disjunctive2.Load());
                Assert.AreEqual(0, repository.TestPolymorphic.Disjunctive.Load().Count());

                var d1 = new TestPolymorphic.Disjunctive1 { ID = Guid.NewGuid(), Name = "abc" };
                repository.TestPolymorphic.Disjunctive1.Insert(new[] { d1 });

                var d2 = new TestPolymorphic.Disjunctive2 { ID = Guid.NewGuid(), Days = 123 };
                repository.TestPolymorphic.Disjunctive2.Insert(new[] { d2 });

                var all = repository.TestPolymorphic.Disjunctive.All();
                Assert.AreEqual(
                    TestUtility.DumpSorted(new[] { d1.ID, d2.ID }),
                    TestUtility.DumpSorted(all, item => item.ID));

                var browseReport = repository.TestPolymorphic.DisjunctiveBrowse.Query()
                    .Select(item => item.Subtype + "-" + item.Disjunctive1.Name + "-" + item.Disjunctive2Days)
                    .ToList();
                Assert.AreEqual(
                    "TestPolymorphic.Disjunctive1-abc-, TestPolymorphic.Disjunctive2--123",
                    TestUtility.DumpSorted(browseReport));
            }
        }