public void WebContentDispatchercontainsTypeTest() { ExecuteTest(() => { WebContentDispatcher container = new WebContentDispatcher(new InMemoryContainer()); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); Assert.IsFalse(container.ContainsType <TestContentType>()); container.Add(c); Assert.IsTrue(container.ContainsType <TestContentType>()); container.Dispose(); }); }
public void WebContentDispatcherAddTest() { ExecuteTest(() => { WebContentDispatcher container = new WebContentDispatcher(new InMemoryContainer()); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); container.Add(c); Guid guid = c.guid; Assert.AreSame(c, container.GetContent <TestContentType>(guid)); container.Dispose(); return(guid.Tiny()); }); }
public void WebContentDispatcherRetriveFromPermanetTest() { ExecuteTest(() => { IContentContainer storage = new InMemoryContainer(); WebContentDispatcher container = new WebContentDispatcher(storage); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); storage.Add(c); Guid guid = c.guid; Assert.IsNotNull(container.GetContent <TestContentType>(c.guid)); container.Dispose(); }); }
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(); }); }
public void WebContentDispatcherStorageHaveDifferentInstaceButSameProperties() { ExecuteTest(() => { IContentContainer storage = new InMemoryContainer(); WebContentDispatcher container = new WebContentDispatcher(storage); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); storage.Add(c); Guid guid = c.guid; Assert.AreNotSame(container.GetContent <TestContentType>(guid), storage.GetContent <TestContentType>(guid)); Assert.IsTrue(container.GetContent <TestContentType>(guid).samePropertiesValue(storage.GetContent <TestContentType>(guid))); container.Dispose(); }); }
public void WebContentDispatcherStorageInstanceAddedOnDispose() { ExecuteTest(() => { IContentContainer storage = new InMemoryContainer(); WebContentDispatcher container = new WebContentDispatcher(storage); this.getMystery().AssemblyRegister.setGlobalObject <IContentDispatcher>(container); TestContentType c = TestContentType.getARandomTestContentTypeWithoutreference(); container.Add(c); Assert.IsFalse(storage.Contains(c)); container.Dispose(); Assert.IsTrue(storage.Contains(c)); this.getMystery().AssemblyRegister.setGlobalObject <IContentDispatcher>(null); }); }
public void WebContentDispatcherWhenRemovedStorageStilHaveIt() { ExecuteTest(() => { IContentContainer storage = new InMemoryContainer(); WebContentDispatcher container = new WebContentDispatcher(storage); this.setGlobalObject <IContentDispatcher>(container); TestContentType c = TestContentType.getARandomTestContentType(enforce_a_reference: false); storage.Add(c); Assert.IsTrue(container.Remove(c)); Assert.IsFalse(container.Contains(c)); Assert.IsTrue(storage.Contains(c)); container.Dispose(); this.setGlobalObject <IContentDispatcher>(null); }); }
public void WebContentDispatcherStorageInstanceUpdateOnDispose() { ExecuteTest(() => { IContentContainer storage = new InMemoryContainer(); string test_value = "ciao"; WebContentDispatcher container = new WebContentDispatcher(storage); this.getMystery().AssemblyRegister.setGlobalObject <IContentDispatcher>(container); TestContentType c = TestContentType.getARandomTestContentTypeWithoutreference(); storage.Add(c); Guid guid = c.guid; TestContentType in_request = container.GetContent <TestContentType>(guid); in_request.a_string = test_value; Assert.AreNotEqual(test_value, c.a_string); container.Dispose(); c = storage.GetContent <TestContentType>(guid); Assert.AreEqual(test_value, c.a_string); this.getMystery().AssemblyRegister.setGlobalObject <IContentDispatcher>(null); }); }
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); }); }