コード例 #1
0
ファイル: FilterTest.cs プロジェクト: ironcev-forks/Rhetos
        public void FilterByReferencedAndLinkedItems()
        {
            using (var container = new RhetosTestContainer())
            {
                container.Resolve <ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestFilter.Source" });
                var repository = container.Resolve <Common.DomRepository>();

                var s1 = new TestFilter.Source {
                    Name = "A s1"
                };
                var s2 = new TestFilter.Source {
                    Name = "B s2"
                };
                repository.TestFilter.Source.Insert(new[] { s1, s2 });
                var d1 = new TestFilter.SourceDetail {
                    ParentID = s1.ID, Name2 = "C d1"
                };
                var d2 = new TestFilter.SourceDetail {
                    ParentID = s2.ID, Name2 = "D d2"
                };
                repository.TestFilter.SourceDetail.Insert(new[] { d1, d2 });

                var filteredDetailByMaster = repository.TestFilter.SourceDetail.Filter(new TestFilter.FilterByPrefix {
                    Prefix = "A"
                });
                Assert.AreEqual("C d1", TestUtility.DumpSorted(filteredDetailByMaster, item => item.Name2));

                var filteredMasterByDetail = repository.TestFilter.Source.Filter(new TestFilter.FilterDetail {
                    Prefix = "C"
                });
                Assert.AreEqual("A s1", TestUtility.DumpSorted(filteredMasterByDetail, item => item.Name));
            }
        }
コード例 #2
0
ファイル: FilterTest.cs プロジェクト: ironcev-forks/Rhetos
        public void FilterByBase()
        {
            using (var container = new RhetosTestContainer())
            {
                container.Resolve <ISqlExecuter>().ExecuteSql(new[] { "DELETE FROM TestFilter.Source" });
                var repository = container.Resolve <Common.DomRepository>();

                var s1 = new TestFilter.Source {
                    ID = Guid.NewGuid(), Name = "A s1"
                };
                var s2 = new TestFilter.Source {
                    ID = Guid.NewGuid(), Name = "B s2"
                };
                var e1 = new TestFilter.SourceExtension {
                    ID = s1.ID, Name2 = "C e1"
                };
                var e2 = new TestFilter.SourceExtension {
                    ID = s2.ID, Name2 = "D e2"
                };
                repository.TestFilter.Source.Insert(new[] { s1, s2 });
                repository.TestFilter.SourceExtension.Insert(new[] { e1, e2 });

                var filteredExtensionByBase = repository.TestFilter.SourceExtension.Filter(new TestFilter.FilterByPrefix {
                    Prefix = "A"
                });
                Assert.AreEqual("C e1", TestUtility.DumpSorted(filteredExtensionByBase, item => item.Name2));
            }
        }