コード例 #1
0
ファイル: FormServiceTests.cs プロジェクト: neozhu/MrCMS
        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);
        }
コード例 #2
0
ファイル: FormServiceTests.cs プロジェクト: neozhu/MrCMS
        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[]>();
        }
コード例 #3
0
ファイル: FormControllerTests.cs プロジェクト: neozhu/MrCMS
        public void FormController_ClearFormDataPOST_ShouldReturnRedirectToRouteResult()
        {
            var stubWebpage = new StubWebpage();

            var result = _formController.ClearFormData_POST(stubWebpage);

            result.Should().BeOfType<RedirectToRouteResult>();
        }
コード例 #4
0
        public void DocumentTagsAdminService_SetTags_IfTagsHasOneStringTheTagListShouldHave1Tag()
        {
            var textPage = new StubWebpage();

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

            textPage.Tags.Should().HaveCount(1);
        }
コード例 #5
0
ファイル: FormControllerTests.cs プロジェクト: neozhu/MrCMS
        public void FormController_ClearFormDataPOST_ShouldRedirectToEditWebpage()
        {
            var stubWebpage = new StubWebpage();

            var result = _formController.ClearFormData_POST(stubWebpage);

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

            _webpageWidgetController.Show(stubWebpage, 2, 3);

            A.CallTo(() => _webpageWidgetAdminService.Show(stubWebpage, 2)).MustHaveHappened();
        }
コード例 #8
0
        public void DocumentTagsAdminService_SetTags_ShouldAddTagsToDocument()
        {
            var textPage = new StubWebpage();

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

            textPage.Tags.Should().HaveCount(2);
        }
コード例 #9
0
ファイル: FormControllerTests.cs プロジェクト: neozhu/MrCMS
        public void FormController_ClearFormData_ShouldReturnPartialViewResult()
        {
            var stubWebpage = new StubWebpage();

            var result = _formController.ClearFormData(stubWebpage);

            result.Should().BeOfType<PartialViewResult>();
        }
コード例 #10
0
        public void DocumentTagsAdminService_SetTags_IfTagsHasTwoCommaSeparatedTagsTheTagListShouldHave2Tags()
        {
            var textPage = new StubWebpage();

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

            textPage.Tags.Should().HaveCount(2);
        }
コード例 #11
0
        public void DocumentTagsAdminService_SetTags_IfTagsIsNullForANewDocumentTheTagListShouldBeEmpty()
        {
            var textPage = new StubWebpage();

            _documentTagsAdminService.SetTags(null, textPage);

            textPage.Tags.Should().HaveCount(0);
        }
コード例 #12
0
ファイル: FormControllerTests.cs プロジェクト: neozhu/MrCMS
        public void FormController_ClearFormDataPOST_ShouldCallClearFormData()
        {
            var stubWebpage = new StubWebpage();

            _formController.ClearFormData_POST(stubWebpage);

            A.CallTo(() => _formAdminService.ClearFormData(stubWebpage)).MustHaveHappened();
        }
コード例 #13
0
ファイル: FormControllerTests.cs プロジェクト: neozhu/MrCMS
        public void FormController_ExportFormData_ShouldReturnFileResult()
        {
            var stubWebpage = new StubWebpage();

            var result = _formController.ExportFormData(stubWebpage);

            result.Should().BeOfType<FileContentResult>();
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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();
        }
コード例 #21
0
ファイル: FormControllerTests.cs プロジェクト: neozhu/MrCMS
        public void FormController_ExportFormData_ShouldCallExportFormData()
        {
            var stubWebpage = new StubWebpage();

            _formController.ExportFormData(stubWebpage);

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

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

            textPage.Tags.Should().HaveCount(2);
        }
コード例 #24
0
        public void WebpageWidgetController_Show_ReturnsARedirectToRouteResult()
        {
            var stubWebpage = new StubWebpage();

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