示例#1
0
        public void Setup()
        {
            // Setup Hive
            _nhibernateTestSetup = new NhibernateTestSetupHelper(useNhProf: true);

            var storageProvider = new IoHiveTestSetupHelper(_nhibernateTestSetup.FakeFrameworkContext);

            Hive =
                new HiveManager(
                    new[]
                        {
                            new ProviderMappingGroup(
                                "test",
                                new WildcardUriMatch("content://"),
                                _nhibernateTestSetup.ReadonlyProviderSetup,
                                _nhibernateTestSetup.ProviderSetup,
                                _nhibernateTestSetup.FakeFrameworkContext),
                            storageProvider.CreateGroup("uploader", "storage://")
                        },
                    _nhibernateTestSetup.FakeFrameworkContext);

            // Setup Schemas
            Hive.Cms()
                .UsingStore<IContentStore>()
                .NewSchema("homepageSchema")
                .Define(NodeNameAttributeDefinition.AliasValue, NodeNameAttributeType.AliasValue, "tab1")
                .Define(SelectedTemplateAttributeDefinition.AliasValue, SelectedTemplateAttributeType.AliasValue, "tab1")
                .Define("siteName", "system-string-type", "tab1")
                .Define("siteDescription", "system-string-type", "tab1")
                .Define("bodyText", "system-long-string-type", "tab2")
                .Commit();

            Hive.Cms()
                .UsingStore<IContentStore>()
                .NewSchema("textpageSchema")
                .Define(NodeNameAttributeDefinition.AliasValue, NodeNameAttributeType.AliasValue, "tab1")
                .Define(SelectedTemplateAttributeDefinition.AliasValue, SelectedTemplateAttributeType.AliasValue, "tab1")
                .Define("bodyText", "system-long-string-type", "tab1")
                .Commit();

            Hive.Cms()
                .UsingStore<IContentStore>()
                .NewSchema("complexpageSchema")
                .Define(NodeNameAttributeDefinition.AliasValue, NodeNameAttributeType.AliasValue, "tab1")
                .Define(SelectedTemplateAttributeDefinition.AliasValue, SelectedTemplateAttributeType.AliasValue, "tab1")
                .Define("color", "system-string-type", "tab1")
                .Define("integer", "system-integer-type", "tab1")
                .Define("date", "system-date-time-type", "tab1")
                .Define("bodyText", "system-long-string-type", "tab1")
                .Commit();

            // Setup Content with a specific DateTime
            _fixedDate = DateTime.Now.Subtract(TimeSpan.FromMinutes(5));
            _homePage = Hive.Cms().NewRevision("Home", "home", "homepageSchema")
                .SetSelectedTemplate(new HiveId("storage", "templates", new HiveIdValue("/homepageTemplate.cshtml")))
                .SetValue("siteName", "Test Site Name")
                .SetValue("siteDescription", "Test Site Description")
                .SetValue("bodyText", "<p>Test Site Body Text</p>")
                .Publish();

            _homePage.Revision.Item.UtcCreated = _fixedDate;
            _homePage.Revision.MetaData.UtcStatusChanged = _fixedDate;
            _homePage.Commit();

            for (var i = 0; i < 5; i++)
            {
                // Create child
                var child = Hive.Cms().NewRevision("Child" + i, "child-" + i, "textpageSchema")
                    .SetSelectedTemplate(new HiveId("storage", "templates", new HiveIdValue("/textpageTemplate.cshtml")))
                    .SetParent(_homePage.Item)
                    .SetValue("bodyText",
                              "<p>Child Content " + i + " Revision 1 " + Guid.NewGuid().ToString() + " " +
                              Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " +
                              Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
                    .Publish()
                    .Commit();

                // Create revisions
                //for (var j = 0; j < i; j++)
                //{
                //    Hive.Cms().NewRevisionOf(child.Item)
                //        .SetValue("bodyText", "<p>Child Content " + i + " Revision " + (j + 2) + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
                //        .Publish()
                //        .Commit();

                //}

                //if (i < 3)
                //{
                //    for (var j = 0; j < 6; j++)
                //    {
                //        // Create grand child
                //        var grandChild = Hive.Cms().NewRevision("Grand Child" + j, "grand-child-" + j, "textpageSchema")
                //            .SetParent(child.Item)
                //            .SetValue("bodyText", "<p>Grand Child Content " + j + " Revision 1 " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
                //            .Publish()
                //            .Commit();

                //        // Create revisions
                //        for (var k = 0; k < j; k++)
                //        {
                //            Hive.Cms().NewRevisionOf(grandChild.Item)
                //                .SetValue("bodyText", "<p>Grand Child Content " + j + " Revision " + (k + 2) + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
                //                .Publish()
                //                .Commit();

                //        }

                //        if (j < 2)
                //        {
                //            // Create great grand children
                //            for (var k = 0; k < 10; k++)
                //            {
                //                var greatGrandChild =
                //                    Hive.Cms().NewRevision("Great Grand Child" + k, "great-grand-child-" + k,
                //                                           "complexpageSchema")
                //                        .SetParent(grandChild.Item)
                //                        .SetValue("color", "#0000" + k.ToString() + k.ToString())
                //                        .SetValue("integer", k)
                //                        .SetValue("date", DateTimeOffset.Now.AddDays(k))
                //                        .SetValue("bodyText",
                //                                  "<p>Great Grand Child Content " + k + " Revision 1 " +
                //                                  Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " +
                //                                  Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " +
                //                                  Guid.NewGuid().ToString() + " the end.</p>")
                //                        .Publish()
                //                        .Commit();

                //                // Create revisions
                //                for (var l = 0; l < k; l++)
                //                {
                //                    Hive.Cms().NewRevisionOf(greatGrandChild.Item)
                //                        .SetValue("bodyText", "<p>Great Grand Child Content " + k + " Revision " + (l + 2) + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
                //                        .Publish()
                //                        .Commit();

                //                }

                //                if (k >= 8)
                //                {
                //                    // Create unpublished revisions
                //                    Hive.Cms().NewRevisionOf(greatGrandChild.Item)
                //                            .SetValue("bodyText", "<p>Great Grand Child Content " + k + " Unpublished Revision " + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
                //                            .Commit();
                //                }
                //            }
                //        }
                //    }
                //}
            }

            //for(var i = 0; i < 2; i++)
            //{
            //    var trashChild = Hive.Cms().NewRevision("Trash Child" + i, "trash-child-" + i, "textpageSchema")
            //        .SetParent(FixedHiveIds.ContentRecylceBin)
            //        .SetValue("bodyText", "<p>Trash Child Content " + i + " Revision 1 " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
            //        .Publish()
            //        .Commit();
            //}
        }
示例#2
0
        public void Setup()
        {
            // Setup Hive
            _nhibernateTestSetup = new NhibernateTestSetupHelper(useNhProf: true);

            var storageProvider = new IoHiveTestSetupHelper(_nhibernateTestSetup.FakeFrameworkContext);

            Hive =
                new HiveManager(
                    new[]
            {
                new ProviderMappingGroup(
                    "test",
                    new WildcardUriMatch("content://"),
                    _nhibernateTestSetup.ReadonlyProviderSetup,
                    _nhibernateTestSetup.ProviderSetup,
                    _nhibernateTestSetup.FakeFrameworkContext),
                storageProvider.CreateGroup("uploader", "storage://")
            },
                    _nhibernateTestSetup.FakeFrameworkContext);

            // Setup Schemas
            Hive.Cms()
            .UsingStore <IContentStore>()
            .NewSchema("homepageSchema")
            .Define(NodeNameAttributeDefinition.AliasValue, NodeNameAttributeType.AliasValue, "tab1")
            .Define(SelectedTemplateAttributeDefinition.AliasValue, SelectedTemplateAttributeType.AliasValue, "tab1")
            .Define("siteName", "system-string-type", "tab1")
            .Define("siteDescription", "system-string-type", "tab1")
            .Define("bodyText", "system-long-string-type", "tab2")
            .Commit();

            Hive.Cms()
            .UsingStore <IContentStore>()
            .NewSchema("textpageSchema")
            .Define(NodeNameAttributeDefinition.AliasValue, NodeNameAttributeType.AliasValue, "tab1")
            .Define(SelectedTemplateAttributeDefinition.AliasValue, SelectedTemplateAttributeType.AliasValue, "tab1")
            .Define("bodyText", "system-long-string-type", "tab1")
            .Commit();

            Hive.Cms()
            .UsingStore <IContentStore>()
            .NewSchema("complexpageSchema")
            .Define(NodeNameAttributeDefinition.AliasValue, NodeNameAttributeType.AliasValue, "tab1")
            .Define(SelectedTemplateAttributeDefinition.AliasValue, SelectedTemplateAttributeType.AliasValue, "tab1")
            .Define("color", "system-string-type", "tab1")
            .Define("integer", "system-integer-type", "tab1")
            .Define("date", "system-date-time-type", "tab1")
            .Define("bodyText", "system-long-string-type", "tab1")
            .Commit();

            // Setup Content with a specific DateTime
            _fixedDate = DateTime.Now.Subtract(TimeSpan.FromMinutes(5));
            _homePage  = Hive.Cms().NewRevision("Home", "home", "homepageSchema")
                         .SetSelectedTemplate(new HiveId("storage", "templates", new HiveIdValue("/homepageTemplate.cshtml")))
                         .SetValue("siteName", "Test Site Name")
                         .SetValue("siteDescription", "Test Site Description")
                         .SetValue("bodyText", "<p>Test Site Body Text</p>")
                         .Publish();

            _homePage.Revision.Item.UtcCreated           = _fixedDate;
            _homePage.Revision.MetaData.UtcStatusChanged = _fixedDate;
            _homePage.Commit();

            for (var i = 0; i < 5; i++)
            {
                // Create child
                var child = Hive.Cms().NewRevision("Child" + i, "child-" + i, "textpageSchema")
                            .SetSelectedTemplate(new HiveId("storage", "templates", new HiveIdValue("/textpageTemplate.cshtml")))
                            .SetParent(_homePage.Item)
                            .SetValue("bodyText",
                                      "<p>Child Content " + i + " Revision 1 " + Guid.NewGuid().ToString() + " " +
                                      Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " +
                                      Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
                            .Publish()
                            .Commit();

                // Create revisions
                //for (var j = 0; j < i; j++)
                //{
                //    Hive.Cms().NewRevisionOf(child.Item)
                //        .SetValue("bodyText", "<p>Child Content " + i + " Revision " + (j + 2) + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
                //        .Publish()
                //        .Commit();

                //}

                //if (i < 3)
                //{
                //    for (var j = 0; j < 6; j++)
                //    {
                //        // Create grand child
                //        var grandChild = Hive.Cms().NewRevision("Grand Child" + j, "grand-child-" + j, "textpageSchema")
                //            .SetParent(child.Item)
                //            .SetValue("bodyText", "<p>Grand Child Content " + j + " Revision 1 " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
                //            .Publish()
                //            .Commit();

                //        // Create revisions
                //        for (var k = 0; k < j; k++)
                //        {
                //            Hive.Cms().NewRevisionOf(grandChild.Item)
                //                .SetValue("bodyText", "<p>Grand Child Content " + j + " Revision " + (k + 2) + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
                //                .Publish()
                //                .Commit();

                //        }

                //        if (j < 2)
                //        {
                //            // Create great grand children
                //            for (var k = 0; k < 10; k++)
                //            {
                //                var greatGrandChild =
                //                    Hive.Cms().NewRevision("Great Grand Child" + k, "great-grand-child-" + k,
                //                                           "complexpageSchema")
                //                        .SetParent(grandChild.Item)
                //                        .SetValue("color", "#0000" + k.ToString() + k.ToString())
                //                        .SetValue("integer", k)
                //                        .SetValue("date", DateTimeOffset.Now.AddDays(k))
                //                        .SetValue("bodyText",
                //                                  "<p>Great Grand Child Content " + k + " Revision 1 " +
                //                                  Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " +
                //                                  Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " +
                //                                  Guid.NewGuid().ToString() + " the end.</p>")
                //                        .Publish()
                //                        .Commit();

                //                // Create revisions
                //                for (var l = 0; l < k; l++)
                //                {
                //                    Hive.Cms().NewRevisionOf(greatGrandChild.Item)
                //                        .SetValue("bodyText", "<p>Great Grand Child Content " + k + " Revision " + (l + 2) + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
                //                        .Publish()
                //                        .Commit();

                //                }

                //                if (k >= 8)
                //                {
                //                    // Create unpublished revisions
                //                    Hive.Cms().NewRevisionOf(greatGrandChild.Item)
                //                            .SetValue("bodyText", "<p>Great Grand Child Content " + k + " Unpublished Revision " + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
                //                            .Commit();
                //                }
                //            }
                //        }
                //    }
                //}
            }

            //for(var i = 0; i < 2; i++)
            //{
            //    var trashChild = Hive.Cms().NewRevision("Trash Child" + i, "trash-child-" + i, "textpageSchema")
            //        .SetParent(FixedHiveIds.ContentRecylceBin)
            //        .SetValue("bodyText", "<p>Trash Child Content " + i + " Revision 1 " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " " + Guid.NewGuid().ToString() + " the end.</p>")
            //        .Publish()
            //        .Commit();
            //}
        }