Beispiel #1
0
 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();
     });
 }
Beispiel #2
0
 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());
     });
 }
Beispiel #3
0
        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();
            });
        }
Beispiel #4
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 #5
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 #6
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();
            });
        }
Beispiel #7
0
        public void WebContentDispatcherNoExceptionTest()
        {
            IContentDispatcher container = null;
            WebActionExecutor  executor  = null;
            ContentsDatabase   db        = this.getGlobalObject <ContentsDatabase>();
            TestContentType    c         = null;

            ExecuteTest(() => {
                container = WebContentDispatcher.getDispatcher();
                c         = TestContentType.getARandomTestContentType(enforce_a_reference: false);
                container.Add(c);
                Guid guid = c.guid;
                executor  = WebActionExecutor.current;
                return(guid.Tiny());
            });
            Assert.IsTrue(executor.status == WebActionExecutorStatus.done);
            Assert.IsTrue(db.Contains(c));
        }
Beispiel #8
0
        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();
            });
        }
Beispiel #9
0
        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);
            });
        }
Beispiel #10
0
        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);
            });
        }
Beispiel #11
0
        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);
            });
        }
Beispiel #12
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);
            });
        }