示例#1
0
        public void SessionHelper_Transact_AllowsNestedCalls()
        {
            var stubWebpage = new StubWebpage();

            this.Invoking(tests => Session.Transact(session => session.Transact(iSession => iSession.Save(stubWebpage))))
                .ShouldNotThrow();
        }
示例#2
0
        public void FormController_Save_CallsFormServiceSaveFormDataWithPassedObjects()
        {
            var stubWebpage = new StubWebpage();
            A.CallTo(() => _documentService.GetDocument<Webpage>(1)).Returns(stubWebpage);
            ActionResult result = _formController.Save(1);

            A.CallTo(() => _formPostingHandler.SaveFormData(stubWebpage, _formController.Request)).MustHaveHappened();
        }
示例#3
0
        public void DefaultFormRenderer_GetDefault_ShouldReturnAnEmptyStringIfThereAreNoProperties()
        {
            var stubWebpage = new StubWebpage();

            var @default = _defaultFormRenderer.GetDefault(stubWebpage, new FormSubmittedStatus(false, null, null));

            @default.Should().Be(string.Empty);
        }
示例#4
0
        public void FormController_Save_SetsTempDataFormSubmittedToTrue()
        {
            var stubWebpage = new StubWebpage();

            A.CallTo(() => _documentService.GetDocument<Webpage>(1)).Returns(stubWebpage);
            ActionResult result = _formController.Save(1);

            _formController.TempData["form-submitted"].Should().Be(true);
        }
示例#5
0
        public void FormController_Save_ReturnsRedirectToTheReferrer()
        {
            var stubWebpage = new StubWebpage();

            A.CallTo(() => _documentService.GetDocument<Webpage>(1)).Returns(stubWebpage);
            ActionResult result = _formController.Save(1);

            result.Should().BeOfType<RedirectResult>();
            result.As<RedirectResult>().Url.Should().Be("http://www.example.com/test-redirect");
        }
示例#6
0
        public void FormRenderer_RenderForm_IfFormDesignHasValueReturnResultCustomRendererGetForm()
        {
            var stubWebpage = new StubWebpage {FormDesign = "form-design-data"};
            var formSubmittedStatus = new FormSubmittedStatus(false, null, null);
            A.CallTo(() => _customFormRenderer.GetForm(stubWebpage, formSubmittedStatus)).Returns("custom-form");

            var renderForm = _formRenderingManager.RenderForm(stubWebpage, formSubmittedStatus);

            renderForm.Should().Be("custom-form");
        }
示例#7
0
        public void FormRenderer_RenderForm_WhenFormDesignIsEmptyReturnsResultOfIDefaultFormRenderer()
        {
            var stubWebpage = new StubWebpage();
            var formSubmittedStatus = new FormSubmittedStatus(false, null, null);
            A.CallTo(() => _defaultFormRenderer.GetDefault(stubWebpage, formSubmittedStatus)).Returns("test-default");

            var renderForm = _formRenderingManager.RenderForm(stubWebpage, formSubmittedStatus);

            renderForm.Should().Be("test-default");
        }
示例#8
0
        public void DefaultFormRenderer_GetDefault_ShouldCallGetElementRendererOnEachProperty()
        {
            var textBox = new TextBox { Name = "test-1" };
            var stubWebpage = new StubWebpage
                                  {
                                      FormProperties = new List<FormProperty> { textBox }
                                  };
            var formElementRenderer = A.Fake<IFormElementRenderer>();
            A.CallTo(() => _elementRendererManager.GetElementRenderer<FormProperty>(textBox))
             .Returns(formElementRenderer);
            A.CallTo(() => formElementRenderer.AppendElement(textBox, _existingValue, _siteSettings.FormRendererType)).Returns(new TagBuilder("input"));

            _defaultFormRenderer.GetDefault(stubWebpage, new FormSubmittedStatus(false, null, _formCollection));

            A.CallTo(() => _elementRendererManager.GetElementRenderer<FormProperty>(textBox)).MustHaveHappened();
        }
示例#9
0
        public void DocumentService_AddDocument_RootDocShouldSetDisplayOrderToMaxOfNonParentDocsPlus1()
        {
            for (int i = 0; i < 4; i++)
            {
                int order = i;
                Session.Transact(session => session.Save(new StubWebpage {DisplayOrder = order, Site = CurrentSite}));
            }

            var stubDocument = new StubWebpage {Site = CurrentSite};
            _documentService.AddDocument(stubDocument);

            stubDocument.DisplayOrder.Should().Be(4);
        }
        private ExcelPackage GetSpreadsheet()
        {
            DateTime currentTime = DateTime.Parse("2013-07-19 15:18:20");
            var document = new StubWebpage
            {
                UrlSegment = "test-url",
                Name = "Test Document",
                BodyContent = "Test Body Content",
                MetaDescription = "Test SEO Description",
                MetaKeywords = "Test, Thought",
                MetaTitle = "Test SEO Title",
                DisplayOrder = 2,
                RevealInNavigation = true,
                RequiresSSL = false,
                PublishOn = currentTime
            };
            document.Tags.Add(new Tag { Id = 1, Name = "Test" });
            document.Urls.Add(new UrlHistory { UrlSegment = "test-url-old" });
            var items = new List<Webpage> { document };

            ExcelPackage exportExcelPackage = new ExportDocumentsService().GetExportExcelPackage(items);

            return exportExcelPackage;
        }
示例#11
0
        public void DefaultFormRenderer_GetDefault_ShouldCallRenderLabelThenRenderElementForEachProperty()
        {
            var textBox1 = new TextBox { Name = "test-1" };
            var textBox2 = new TextBox { Name = "test-2" };

            var stubWebpage = new StubWebpage
            {
                FormProperties = new List<FormProperty> { textBox1, textBox2 }
            };
            var formElementRenderer = A.Fake<IFormElementRenderer>();
            A.CallTo(() => formElementRenderer.AppendElement(textBox1, _existingValue, _siteSettings.FormRendererType)).Returns(new TagBuilder("input"));
            A.CallTo(() => formElementRenderer.AppendElement(textBox2, _existingValue, _siteSettings.FormRendererType)).Returns(new TagBuilder("input"));
            A.CallTo(() => _elementRendererManager.GetElementRenderer<FormProperty>(textBox1))
             .Returns(formElementRenderer);
            A.CallTo(() => _elementRendererManager.GetElementRenderer<FormProperty>(textBox2))
             .Returns(formElementRenderer);

            _defaultFormRenderer.GetDefault(stubWebpage, new FormSubmittedStatus(false, null, _formCollection));

            List<ICompletedFakeObjectCall> elementRendererCalls = Fake.GetCalls(formElementRenderer).ToList();
            List<ICompletedFakeObjectCall> labelRendererCalls = Fake.GetCalls(_labelRenderer).ToList();

            labelRendererCalls.Where(x => x.Method.Name == "AppendLabel").Should().HaveCount(2);
            elementRendererCalls.Where(x => x.Method.Name == "AppendElement").Should().HaveCount(2);
        }