Beispiel #1
0
        public void WebContentDispatchergetAllTest()
        {
            ExecuteTest(() => {
                WebContentDispatcher container = new WebContentDispatcher(new InMemoryContainer());
                this.setGlobalObject <IContentDispatcher>(container);
                List <IContent> contents = new List <IContent>(from int i in Enumerable.Range(0, rnd.Next(10) + 2)
                                                               select TestContentType.getARandomTestContentType(enforce_a_reference: false));

                container.AddContents(contents);

                List <IContent> type2 = new List <IContent>(from int i in Enumerable.Range(0, rnd.Next(10) + 2)
                                                            select new TestContentType2());
                container.AddContents(type2);

                Assert.IsTrue(container.GetAll <TestContentType2>().sameContents(type2));
                Assert.IsTrue(container.GetAll <TestContentType>().sameContents(type2.Union(contents)));

                container.Dispose();
                this.setGlobalObject <IContentDispatcher>(null);
            });
        }
Beispiel #2
0
        public void WebContentDispatcheraddContentsTest()
        {
            ExecuteTest(() => {
                WebContentDispatcher container = new WebContentDispatcher(new InMemoryContainer());
                List <IContent> contents       = new List <IContent>(from int i in Enumerable.Range(0, rnd.Next(10) + 2)
                                                                     select TestContentType.getARandomTestContentType(enforce_a_reference: false));

                container.AddContents(contents);

                Assert.AreEqual(container.Count, contents.Count);
                container.Dispose();
            });
        }
Beispiel #3
0
        public void WebContentDispatchersearchTest()
        {
            ExecuteTest(() => {
                WebContentDispatcher container  = new WebContentDispatcher(new InMemoryContainer());
                List <TestContentType> contents = new List <TestContentType>(from int i in Enumerable.Range(0, rnd.Next(10) + 2)
                                                                             select TestContentType.getARandomTestContentType(enforce_a_reference: false));

                container.AddContents(contents);
                Assert.IsTrue(container.Search(contents[0].the_reference_text, 10).Count() == 1);
                Assert.IsTrue(container.Search(contents[0].the_reference_text.Replace("-", " "), 10).Count() >= 1);
                Assert.IsTrue(container.Search(contents[0].the_reference_text.Split('-')[0], 10).Count() >= 1);
                container.Dispose();
            });
        }
Beispiel #4
0
        public void WebContentDispatchergetAllByFilterTest()
        {
            ExecuteTest(() => {
                WebContentDispatcher container  = new WebContentDispatcher(new InMemoryContainer());
                List <TestContentType> contents = new List <TestContentType>(from int i in Enumerable.Range(0, rnd.Next(10) + 2)
                                                                             select TestContentType.getARandomTestContentType(enforce_a_reference: false));

                container.AddContents(contents);


                Assert.IsTrue(container.GetAllByFilter <TestContentType>(
                                  x => x.a_string == contents[0].a_string || x.a_string == contents[1].a_string)
                              .sameContents(contents.Take(2)));
                container.Dispose();
            });
        }