Beispiel #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);
        }
Beispiel #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[]>();
        }
Beispiel #3
0
        public void FormController_ClearFormDataPOST_ShouldReturnRedirectToRouteResult()
        {
            var stubWebpage = new StubWebpage();

            var result = _formController.ClearFormData_POST(stubWebpage);

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

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

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

            var result = _formController.ClearFormData_POST(stubWebpage);

            result.RouteValues["action"].Should().Be("Edit");
        }
        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");
        }
        public void WebpageWidgetController_Show_CallsDocumentServiceShowWithPassedArguments()
        {
            var stubWebpage = new StubWebpage();

            _webpageWidgetController.Show(stubWebpage, 2, 3);

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

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

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

            var result = _formController.ClearFormData(stubWebpage);

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

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

            textPage.Tags.Should().HaveCount(2);
        }
        public void DocumentTagsAdminService_SetTags_IfTagsIsNullForANewDocumentTheTagListShouldBeEmpty()
        {
            var textPage = new StubWebpage();

            _documentTagsAdminService.SetTags(null, textPage);

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

            _formController.ClearFormData_POST(stubWebpage);

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

            var result = _formController.ExportFormData(stubWebpage);

            result.Should().BeOfType<FileContentResult>();
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        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();
        }
Beispiel #21
0
        public void FormController_ExportFormData_ShouldCallExportFormData()
        {
            var stubWebpage = new StubWebpage();

            _formController.ExportFormData(stubWebpage);

            A.CallTo(() => _formAdminService.ExportFormData(stubWebpage)).MustHaveHappened();
        }
        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);
        }
        public void DocumentTagsAdminService_SetTags_ShouldNotCreateTagsWithEmptyNamesForTrailingComma()
        {
            var textPage = new StubWebpage();

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

            textPage.Tags.Should().HaveCount(2);
        }
        public void WebpageWidgetController_Show_ReturnsARedirectToRouteResult()
        {
            var stubWebpage = new StubWebpage();

            _webpageWidgetController.Show(stubWebpage, 2, 3).Should().BeOfType<RedirectToRouteResult>();
        }
Beispiel #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");
        }