Esempio n. 1
0
        public void PageEditorError_Call_LogError(string errorMessage, FakeSiteContext siteContext, MemoryAppender appender, [RegisterView(ViewPath.InfoMessage)] IView view, HtmlHelper htmlHelper)
        {
            //Arrange
            typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Edit);
            BasicConfigurator.Configure(appender);

            //Act
            using (new SiteContextSwitcher(siteContext))
            {
                AlertHtmlHelpers.PageEditorError(htmlHelper, errorMessage);
            }

            //Assert
            appender.Events.Should().Contain(x => x.RenderedMessage.Contains(errorMessage));
        }
Esempio n. 2
0
        public void PageEditorError_EditMode_RenderErrorView(string errorMessage, FakeSiteContext siteContext, [RegisterView(ViewPath.InfoMessage)] IView view, HtmlHelper helper)
        {
            //Arrange
            typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Edit);

            //Act
            MvcHtmlString result;

            using (new SiteContextSwitcher(siteContext))
            {
                result = AlertHtmlHelpers.PageEditorError(helper, errorMessage);

                //Assert
                view.Received().Render(Arg.Is <ViewContext>(v => v.ViewData.Model.As <InfoMessage>().Type == InfoMessage.MessageType.Error), Arg.Any <TextWriter>());
            }
        }
Esempio n. 3
0
        public void PageEditorError_NormalMode_ReturnEmptyString(string errorMessage, FakeSiteContext siteContext)
        {
            //Arrange
            typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Normal);

            //Act
            MvcHtmlString result;

            using (new SiteContextSwitcher(siteContext))
            {
                result = AlertHtmlHelpers.PageEditorError(null, errorMessage);
            }

            //Assert
            result.ToString().Should().BeEmpty();
        }