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); }); }
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(); }); }
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(); }); }
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(); }); }