コード例 #1
0
        public void SigleReferenceSuggestionsActionCanNotTest()
        {
            using (WebActionExecutor executor = new WebActionExecutor())
            {
                //we add Adriano in db
                TestContentType  adriano = TestContentType.getARandomTestContentType(enforce_a_reference: true);
                ContentsDatabase db      = this.getGlobalObject <ContentsDatabase>();
                db.Add(adriano);
                //we became not admin
                MysterySession session  = this.getGlobalObject <MysterySession>();
                var            was_adim = session.authenticated_user.account_type == UserType.admin;
                if (was_adim)
                {
                    session.authenticated_user.account_type = UserType.normal;
                }

                var result = executor.executeAction(
                    new SigleReferenceSuggestionsAction(),
                    new PropertyEditSuggestionsActionInput
                {
                    content_reference = new Mystery.Content.ContentReference(adriano),
                    property_name     = nameof(TestContentType.not_ediatable_reference),
                    search_text       = null
                });
                Assert.IsTrue(!result.isSuccessfull && result.UnAuthorized);
                if (was_adim)
                {
                    session.authenticated_user.account_type = UserType.admin;
                }
            }
        }
コード例 #2
0
        ////<root>
        ////    <wrap>
        ////        <item1 />
        ////        <item2></item2>
        ////        <item2a> </item2a>
        ////        <item2b>
        ////        </item2b>
        ////        <item2c><![CDATA[
        ////        ]]></item2c>
        ////        <item3>blah</item3>
        ////        <item4>
        ////            <subitem x=""1"">bam</subitem>
        ////        </item4>
        ////        <item5>
        ////        </item5>
        ////    </wrap>
        ////</root>

        public TestSource6()
        {
            LastAttributeIndex = -1;

            var             type  = new TestRootContentType(this);
            TestContentType type1 = type.CreateType(
                "wrap",
                new TestPropertyType("item1"),
                new TestPropertyType("item2"),
                new TestPropertyType("item2a"),
                new TestPropertyType("item2b"),
                new TestPropertyType("item2c"),
                new TestPropertyType("item3"),
                new TestPropertyType("item3a"),
                new TestPropertyType("item4", true),
                new TestPropertyType("item5", true));

            Content[1] = new TestContent(type1, 1, -1)
                         .WithValues(
                null,
                null,
                null,
                null,
                "\n        ",
                "blah",
                "\n            blah\n        ",
                "<subitem x=\"1\">bam</subitem>",
                "\n        ");

            Root = new TestRootContent(type).WithChildren(1);
        }
コード例 #3
0
        public void ContentServiceContentViewTest()
        {
            var c  = TestContentType.getARandomTestContentType(enforce_a_reference: true);
            var cd = this.getGlobalObject <IContentDispatcher>();

            cd.Add(c);
            cd.AddContents(c.single_reference.getAsContentEnum());
            cd.AddContents(c.multi_reference.getAsContentEnum());
            var uid            = c.guid.Tiny();
            var s              = new ContentService();
            var service_result = s.ContentView(nameof(TestContentType), uid);
            var converter      = this.getGlobalObject <IMysteryJsonUiConverter>();
            var cui            = converter.readJson <ContentUi>(service_result.json_output);

            foreach (PropertyView property_view in typeof(TestContentType).getMysteryPropertyAttributes <PropertyView>())
            {
                var    cp   = property_view.used_in.getMysteryAttribute <ContentProperty>();
                string name = cp == null ? property_view.used_in.Name : cp.name;

                Assert.IsTrue(cui.propertiesUi.ContainsKey(name));
                Assert.AreEqual(cui.propertiesUi[name].content.property_name, name);
            }

            Assert.AreEqual(cui.propertiesUi[nameof(TestContentType.a_string)].content.property_value, c.a_string);
            Assert.AreEqual(cui.propertiesUi[nameof(TestContentType.a_integer)].content.property_value, c.a_integer);
            Assert.AreEqual(cui.propertiesUi[nameof(TestContentType.a_double)].content.property_value, c.a_double);
            Assert.AreEqual(cui.propertiesUi[nameof(TestContentType.a_boolean)].content.property_value, c.a_boolean);
            Assert.AreEqual(cui.propertiesUi[nameof(TestContentType.a_enum)].content.property_value.ToString(), c.a_enum.ToString());
        }
コード例 #4
0
        public void MongoContentCollectionContainsTest()
        {
            var collection = new MongoContentCollection <TestContentType>();
            var probe      = TestContentType.getARandomTestContentType(enforce_a_reference: false);

            Assert.IsFalse(collection.Contains(probe));
            collection.Add(probe);
            Assert.IsTrue(collection.Contains(probe));
        }
コード例 #5
0
        public void containsTypeTest()
        {
            IContentContainer container = getContainer();
            TestContentType   c         = TestContentType.getARandomTestContentType(enforce_a_reference: false);

            Assert.IsFalse(container.ContainsType <TestContentType>());
            container.Add(c);
            Assert.IsTrue(container.ContainsType <TestContentType>());
        }
コード例 #6
0
        public void MongoContentCollectionAddTest()
        {
            var collection = new MongoContentCollection <TestContentType>();

            collection.Clear();
            var probe = TestContentType.getARandomTestContentType(enforce_a_reference: false);

            collection.Add(probe);
            Assert.IsFalse(collection.isEmpty);
        }
コード例 #7
0
        public void MongoContentCollectionGetContentTest()
        {
            var collection = new MongoContentCollection <TestContentType>();
            var probe      = TestContentType.getARandomTestContentType(enforce_a_reference: false);

            collection.Add(probe);
            var back_from_collection = collection.GetContent(probe.guid);

            Assert.IsTrue(back_from_collection.samePropertiesValue(probe));
        }
コード例 #8
0
        public void addContentsTest()
        {
            IContentContainer container = getContainer();
            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);
        }
コード例 #9
0
        public void MongoContentCollectionAddContentsTest()
        {
            var collection = new MongoContentCollection <TestContentType>();

            collection.Clear();
            collection.AddContents(from x in Enumerable.Range(0, 10) select
                                   TestContentType.getARandomTestContentType(enforce_a_reference: false));

            Assert.IsTrue(collection.Count == 10);
        }
コード例 #10
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();
     });
 }
コード例 #11
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());
     });
 }
コード例 #12
0
        public void getLightContentRerefereceTest()
        {
            using (WebActionExecutor executor = new WebActionExecutor()) {
                IContentContainer container = getContainer();
                TestContentType   c         = TestContentType.getARandomTestContentType(enforce_a_reference: false);
                container.Add(c);
                LightContentReferece light_reference = container.GetLightContentRereferece <TestContentType>().FirstOrDefault();

                Assert.AreEqual(light_reference.ReferenceText, c.ReferenceText);
                Assert.AreEqual(light_reference.guid, c.guid);
            }
        }
コード例 #13
0
 public void RemoveTest()
 {
     using (WebActionExecutor executor = new WebActionExecutor()) {
         IContentContainer container = getContainer();
         TestContentType   c         = TestContentType.getARandomTestContentType(enforce_a_reference: false);
         container.Add(c);
         Assert.IsTrue(container.Remove(c));
         c = TestContentType.getARandomTestContentType(enforce_a_reference: false);
         Assert.IsFalse(container.Remove(c));
         Assert.AreEqual(container.Count, 0);
     }
 }
コード例 #14
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();
            });
        }
コード例 #15
0
        public void SingleReferencePropertyValuesProviderAttgetProviderTest()
        {
            var cd = this.getGlobalObject <IContentDispatcher>();

            cd.Add(TestContentType.getARandomTestContentTypeWithoutreference());

            //let's try to just call it
            foreach (var provider_att in typeof(TestContentType).getMysteryPropertyAttributes <SingleReferencePropertyValuesProviderAtt>())
            {
                var result = provider_att.getProvider().getSuggestions(null, "");
                Assert.IsTrue(result.Count() > 0);
            }
        }
コード例 #16
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();
            });
        }
コード例 #17
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();
            });
        }
コード例 #18
0
        public TestSource2()
        {
            LastAttributeIndex = -1;

            var             prop1 = new TestPropertyType("prop1", true);
            var             type  = new TestRootContentType(this);
            TestContentType type1 = type.CreateType("type1", prop1);

            const string xml = "<data><item1>poo</item1><item2 xx=\"33\" /><item2 xx=\"34\" /></data>";

            Content[1] = new TestContent(type1, 1, 1).WithValues(xml);

            Root = new TestRootContent(type).WithChildren(1);
        }
コード例 #19
0
        public TestSource4()
        {
            LastAttributeIndex = -1;

            var             prop1 = new TestPropertyType("prop1", true);
            var             prop2 = new TestPropertyType("prop2");
            var             type  = new TestRootContentType(this);
            TestContentType type1 = type.CreateType("type1", prop1, prop2);

            Content[1] = new TestContent(type1, 1, -1).WithValues("<data value=\"value\"/>", "dang");
            Content[2] = new TestContent(type1, 2, -1).WithValues(null, string.Empty);
            Content[3] = new TestContent(type1, 3, -1).WithValues(null, null);

            Root = new TestRootContent(type).WithChildren(1, 2, 3);
        }
コード例 #20
0
        public void getAllByFilterTest()
        {
            using (WebActionExecutor executor = new WebActionExecutor()){
                IContentContainer      container = getContainer();
                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)));
            }
        }
コード例 #21
0
        public void MongoContentCollectionGetAllTest()
        {
            var collection = new MongoContentCollection <TestContentType>();

            collection.Clear();
            var contents = new List <TestContentType>(
                from x in Enumerable.Range(0, 10)
                select TestContentType.getARandomTestContentType(enforce_a_reference: false));

            collection.AddContents(contents);
            var basket_one = new MultiContentReference <TestContentType>(contents);
            var basket_two = new MultiContentReference <TestContentType>(collection.GetAll().Cast <TestContentType>());

            Assert.AreEqual(basket_one, basket_two);
        }
コード例 #22
0
        public TestSource3()
        {
            LastAttributeIndex = 1;

            var             prop1 = new TestPropertyType("prop1");
            var             prop2 = new TestPropertyType("prop2");
            var             prop3 = new TestPropertyType("prop3");
            var             type  = new TestRootContentType(this, prop1, prop2);
            TestContentType type1 = type.CreateType("type1", prop3);

            Content[1] = new TestContent(type1, 1, 1).WithValues("1:p1", "1:p2", "1:p3").WithChildren(2);
            Content[2] = new TestContent(type1, 2, 1).WithValues("2:p1", "2:p2", "2:p3");

            Root = new TestRootContent(type).WithChildren(1);
        }
コード例 #23
0
        public TestSource1()
        {
            // last attribute index is 1 -  meaning properties 0 and 1 are attributes, 2+ are elements
            // then, fieldValues must have adequate number of items
            LastAttributeIndex = 1;

            var             prop1 = new TestPropertyType("prop1");
            var             prop2 = new TestPropertyType("prop2");
            var             prop3 = new TestPropertyType("prop3");
            var             type  = new TestRootContentType(this, prop1, prop2);
            TestContentType type1 = type.CreateType("type1", prop3);

            Content[1] = new TestContent(type1, 1, -1).WithValues("1:p1", "1:p2", "1:p3");

            Root = new TestRootContent(type).WithValues(string.Empty, string.Empty).WithChildren(1);
        }
コード例 #24
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();
            });
        }
コード例 #25
0
        public TestSource8()
        {
            LastAttributeIndex = 0;

            var             attr  = new TestPropertyType("attr");
            var             prop  = new TestPropertyType("prop");
            var             type  = new TestRootContentType(this, attr);
            TestContentType type1 = type.CreateType("item", attr, prop);

            Content[1] = new TestContent(type1, 1, -1).WithValues(null, null);
            Content[2] = new TestContent(type1, 2, -1).WithValues(string.Empty, string.Empty);
            Content[3] = new TestContent(type1, 3, -1).WithValues("   ", "   ");
            Content[4] = new TestContent(type1, 4, -1).WithValues(string.Empty, "\n");
            Content[5] = new TestContent(type1, 5, -1).WithValues("  ooo  ", "   ooo   ");
            Root       = new TestRootContent(type).WithValues(null).WithChildren(1, 2, 3, 4, 5);
        }
コード例 #26
0
        public void MongoContentCollectionRemoveContentsTest()
        {
            var collection = new MongoContentCollection <TestContentType>();

            collection.Clear();
            var probe    = TestContentType.getARandomTestContentType(enforce_a_reference: false);
            var contents = new List <IContent>(from x in Enumerable.Range(0, 10)
                                               select TestContentType.getARandomTestContentType(enforce_a_reference: false));

            contents.Add(probe);
            collection.AddContents(contents);

            Assert.IsTrue(collection.Contains(probe));
            collection.Remove(probe);
            Assert.IsFalse(collection.Contains(probe));
        }
コード例 #27
0
        public void ContentServiceContentTest()
        {
            var c = TestContentType.getARandomTestContentType(enforce_a_reference: false);

            //let's avoid single reference
            c.single_reference = new ContentReference <TestContentType>();
            ContentsDatabase db = this.getGlobalObject <ContentsDatabase>();

            db.Add(c);
            db.AddContents(c.multi_reference.getAsContentEnum());
            var uid            = c.guid.Tiny();
            var s              = new ContentService();
            var service_result = s.ContentView(nameof(TestContentType), uid);
            var converter      = this.getGlobalObject <IMysteryJsonUiConverter>();

            Assert.IsTrue(converter.readJson <IContent>(service_result.json_output) is TestContentType);
        }
コード例 #28
0
        public void GetEnumeratorTest()
        {
            using (WebActionExecutor executor = new WebActionExecutor()) {
                IContentContainer      container = getContainer();
                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);
                int tot = 0;
                foreach (IContent c in container)
                {
                    tot += 1;
                }

                Assert.AreEqual(contents.Count, tot);
            }
        }
コード例 #29
0
        public void AddTest()
        {
            IContentContainer container = getContainer();
            TestContentType   c         = TestContentType.getARandomTestContentType(enforce_a_reference: true);

            container.Add(c.single_reference.value);
            foreach (var r in c.multi_reference)
            {
                container.Add(r.value);
            }
            container.Add(c);
            Guid guid = c.guid;
            var  back_from_container = container.GetContent <TestContentType>(guid);

            Assert.AreEqual(c.guid, back_from_container.guid);
            Assert.IsTrue(c.samePropertiesValue(back_from_container));
            Assert.AreEqual(c.GetType(), back_from_container.GetType());
        }
コード例 #30
0
        public void getAllTest()
        {
            using (WebActionExecutor executor = new WebActionExecutor()) {
                IContentContainer container = getContainer();
                container.Clear();
                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)));
            }
        }