Ejemplo n.º 1
0
        public void FormAdminService_ClearFormData_ShouldDeleteFormPosting()
        {
            var webpage = new StubWebpage();
            var posting = new FormPosting
            {
                IsDeleted = false,
                Webpage = webpage,
                FormValues = new List<FormValue>
                {
                    new FormValue
                    {
                        IsDeleted = false,
                        IsFile = false,
                        Key = "Name",
                        Value = "MrCMS"
                    }
                }
            };

            webpage.FormPostings = new List<FormPosting> {posting};

            Session.Transact(session => session.Save(posting));

            _formAdminService.ClearFormData(webpage);

            Session.QueryOver<FormPosting>().RowCount().Should().Be(0);
        }
Ejemplo n.º 2
0
        public void FormAdminService_ExportFormData_ShouldReturnByteArray()
        {
            var webpage = new StubWebpage();
            var posting = new FormPosting
            {
                IsDeleted = false,
                Webpage = webpage,
                FormValues = new List<FormValue>
                {
                    new FormValue
                    {
                        IsDeleted = false,
                        IsFile = false,
                        Key = "Name",
                        Value = "MrCMS"
                    }
                }
            };

            webpage.FormPostings = new List<FormPosting> {posting};

            byte[] result = _formAdminService.ExportFormData(webpage);

            result.Should().BeOfType<byte[]>();
        }
Ejemplo n.º 3
0
        public void FormController_ClearFormDataPOST_ShouldReturnRedirectToRouteResult()
        {
            var stubWebpage = new StubWebpage();

            var result = _formController.ClearFormData_POST(stubWebpage);

            result.Should().BeOfType<RedirectToRouteResult>();
        }
Ejemplo n.º 4
0
        public void DocumentTagsAdminService_SetTags_IfTagsHasOneStringTheTagListShouldHave1Tag()
        {
            var textPage = new StubWebpage();

            _documentTagsAdminService.SetTags("test tag", textPage);

            textPage.Tags.Should().HaveCount(1);
        }
Ejemplo n.º 5
0
        public void FormController_ClearFormDataPOST_ShouldRedirectToEditWebpage()
        {
            var stubWebpage = new StubWebpage();

            var result = _formController.ClearFormData_POST(stubWebpage);

            result.RouteValues["action"].Should().Be("Edit");
        }
Ejemplo n.º 6
0
        public void DocumentTagsAdminService_SetTags_ShouldTrimTagNames()
        {
            var textPage = new StubWebpage();

            _documentTagsAdminService.SetTags("test 1, test 2", textPage);

            textPage.Tags.ElementAt(1).Name.Should().Be("test 2");
        }
Ejemplo n.º 7
0
        public void WebpageWidgetController_Show_CallsDocumentServiceShowWithPassedArguments()
        {
            var stubWebpage = new StubWebpage();

            _webpageWidgetController.Show(stubWebpage, 2, 3);

            A.CallTo(() => _webpageWidgetAdminService.Show(stubWebpage, 2)).MustHaveHappened();
        }
Ejemplo n.º 8
0
        public void DocumentTagsAdminService_SetTags_ShouldAddTagsToDocument()
        {
            var textPage = new StubWebpage();

            _documentTagsAdminService.SetTags("test 1, test 2", textPage);

            textPage.Tags.Should().HaveCount(2);
        }
Ejemplo n.º 9
0
        public void FormController_ClearFormData_ShouldReturnPartialViewResult()
        {
            var stubWebpage = new StubWebpage();

            var result = _formController.ClearFormData(stubWebpage);

            result.Should().BeOfType<PartialViewResult>();
        }
Ejemplo n.º 10
0
        public void DocumentTagsAdminService_SetTags_IfTagsHasTwoCommaSeparatedTagsTheTagListShouldHave2Tags()
        {
            var textPage = new StubWebpage();

            _documentTagsAdminService.SetTags("test 1, test 2", textPage);

            textPage.Tags.Should().HaveCount(2);
        }
Ejemplo n.º 11
0
        public void DocumentTagsAdminService_SetTags_IfTagsIsNullForANewDocumentTheTagListShouldBeEmpty()
        {
            var textPage = new StubWebpage();

            _documentTagsAdminService.SetTags(null, textPage);

            textPage.Tags.Should().HaveCount(0);
        }
Ejemplo n.º 12
0
        public void FormController_ClearFormDataPOST_ShouldCallClearFormData()
        {
            var stubWebpage = new StubWebpage();

            _formController.ClearFormData_POST(stubWebpage);

            A.CallTo(() => _formAdminService.ClearFormData(stubWebpage)).MustHaveHappened();
        }
Ejemplo n.º 13
0
        public void FormController_ExportFormData_ShouldReturnFileResult()
        {
            var stubWebpage = new StubWebpage();

            var result = _formController.ExportFormData(stubWebpage);

            result.Should().BeOfType<FileContentResult>();
        }
Ejemplo n.º 14
0
        public void WebpageWidgetController_Show_SetsRouteValuesForIdAndLayoutAreaId()
        {
            var stubWebpage = new StubWebpage {Id = 1};

            var redirectToRouteResult = _webpageWidgetController.Show(stubWebpage, 2, 3).As<RedirectToRouteResult>();

            redirectToRouteResult.RouteValues["action"].Should().Be("Edit");
            redirectToRouteResult.RouteValues["id"].Should().Be(stubWebpage.Id);
            redirectToRouteResult.RouteValues["layoutAreaId"].Should().Be(3);
        }
Ejemplo n.º 15
0
        public void WebpageWidgetAdminService_ShowWidget_AddsAWidgetToTheShownWidgetsListIfItIsNotInTheHiddenList()
        {
            var textPage = new StubWebpage { ShownWidgets = new HashSet<Widget>(), HiddenWidgets = new HashSet<Widget>() };
            Session.Transact(session => session.Save(textPage));

            var textWidget = new BasicMappedWidget();
            Session.Transact(session => session.Save(textWidget));

            _webpageWidgetAdminService.Show(textPage, textWidget.Id);

            textPage.ShownWidgets.Should().Contain(textWidget);
        }
Ejemplo n.º 16
0
        public void WebpageWidgetAdminService_HideWidget_DoesNothingIfTheWidgetIdIsInvalid()
        {
            var textWidget = new BasicMappedWidget();
            Session.Transact(session => session.Save(textWidget));

            var textPage = new StubWebpage
            {
                ShownWidgets = new HashSet<Widget> { textWidget },
                HiddenWidgets = new HashSet<Widget>()
            };
            Session.Transact(session => session.Save(textPage));

            _webpageWidgetAdminService.Hide(textPage, -1);

            textPage.ShownWidgets.Should().Contain(textWidget);
        }
Ejemplo n.º 17
0
        public void WebpageWidgetAdminService_HideWidget_RemovesAWidgetFromTheShownListIfItIsIncluded()
        {

            var textWidget = new BasicMappedWidget();
            Session.Transact(session => session.Save(textWidget));

            var textPage = new StubWebpage
            {
                ShownWidgets = new HashSet<Widget> { textWidget },
                HiddenWidgets = new HashSet<Widget>()
            };
            Session.Transact(session => session.Save(textPage));

            _webpageWidgetAdminService.Hide(textPage, textWidget.Id);

            textPage.ShownWidgets.Should().NotContain(textWidget);
        }
Ejemplo n.º 18
0
        public void DocumentTagsAdminService_SetTags_ShouldNotRecreateTags()
        {
            var textPage = new StubWebpage();
            var tag1 = new Tag {Name = "test 1"};
            var tag2 = new Tag {Name = "test 2"};
            textPage.Tags.Add(tag1);
            textPage.Tags.Add(tag2);

            Session.Transact(session =>
            {
                session.SaveOrUpdate(textPage);
                session.SaveOrUpdate(tag1);
                session.SaveOrUpdate(tag2);
            });

            _documentTagsAdminService.SetTags(textPage.TagList, textPage);

            Session.QueryOver<Tag>().RowCount().Should().Be(2);
        }
Ejemplo n.º 19
0
        public void DocumentTagsAdminService_SetTags_ShouldAssignDocumentToTag()
        {
            var textPage = new StubWebpage();
            Session.Transact(session => session.SaveOrUpdate(textPage));

            _documentTagsAdminService.SetTags("test 1", textPage);

            var tags = textPage.Tags;
            tags.Should().HaveCount(1);
            tags.First().Documents.Should().HaveCount(1);
        }
Ejemplo n.º 20
0
        public void WebpageWidgetAdminService_ShowWidget_CallsSaveDocumentOnWebpage()
        {
            var textPage = new StubWebpage { ShownWidgets = new HashSet<Widget>(), HiddenWidgets = new HashSet<Widget>() };
            Session.Transact(session => session.Save(textPage));

            var textWidget = new BasicMappedWidget();
            Session.Transact(session => session.Save(textWidget));

            _webpageWidgetAdminService.Show(textPage, textWidget.Id);

            A.CallTo(() => _documentService.SaveDocument<Webpage>(textPage)).MustHaveHappened();
        }
Ejemplo n.º 21
0
        public void FormController_ExportFormData_ShouldCallExportFormData()
        {
            var stubWebpage = new StubWebpage();

            _formController.ExportFormData(stubWebpage);

            A.CallTo(() => _formAdminService.ExportFormData(stubWebpage)).MustHaveHappened();
        }
Ejemplo n.º 22
0
        public void DocumentTagsAdminService_SetTags_ShouldRemoveTheDocumentFromTags()
        {
            var textPage = new StubWebpage();
            var tag1 = new Tag {Name = "test 1"};
            var tag2 = new Tag {Name = "test 2"};
            textPage.Tags.Add(tag1);
            textPage.Tags.Add(tag2);
            tag1.Documents.Add(textPage);
            tag2.Documents.Add(textPage);

            Session.Transact(session =>
            {
                session.SaveOrUpdate(textPage);
                session.SaveOrUpdate(tag1);
                session.SaveOrUpdate(tag2);
            });

            _documentTagsAdminService.SetTags("test 1", textPage);

            tag1.Documents.Should().HaveCount(1);
            tag2.Documents.Should().HaveCount(0);
        }
Ejemplo n.º 23
0
        public void DocumentTagsAdminService_SetTags_ShouldNotCreateTagsWithEmptyNamesForTrailingComma()
        {
            var textPage = new StubWebpage();

            _documentTagsAdminService.SetTags("test 1, test 2, ", textPage);

            textPage.Tags.Should().HaveCount(2);
        }
Ejemplo n.º 24
0
        public void WebpageWidgetController_Show_ReturnsARedirectToRouteResult()
        {
            var stubWebpage = new StubWebpage();

            _webpageWidgetController.Show(stubWebpage, 2, 3).Should().BeOfType<RedirectToRouteResult>();
        }
Ejemplo n.º 25
0
        public void WebpageController_Delete_ReturnsRedirectToIndex()
        {
            var stubWebpage = new StubWebpage();

            _webpageController.Delete(stubWebpage).Should().BeOfType<RedirectToRouteResult>();
            _webpageController.Delete(stubWebpage).As<RedirectToRouteResult>().RouteValues["action"].Should()
                .Be("Index");
        }