//protected HtmlHelper Html { get; set; }

        protected ControllerTests()
        {
            TestAuthenticationAndAuthorization.SetTestUserToCurrentPrincipal();
            Repository        = Substitute.For <IRepository>();
            SettingsProvider  = Substitute.For <ISettingsProvider>();
            ContentRenderer   = Substitute.For <IContentRenderer>();
            ControllerContext = CreateControllerContext();
            UrlHelper         = CreateUrlHelper();
            SettingsProvider.GetSettings <FunnelWebSettings>().Returns(new FunnelWebSettings {
                EnablePublicHistory = true
            });
            //Html = CreateHelper();
            ContentRenderer.RenderTrusted(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <HtmlHelper>()).Returns(c => c.Args()[0]);
            ContentRenderer.RenderUntrusted(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <HtmlHelper>()).Returns(c => c.Args()[0]);
        }
Exemple #2
0
        public void WikiControllerTestsPageReturnsFoundPage()
        {
            TestAuthenticationAndAuthorization.SetTestUserToCurrentPrincipal();

            var entry = new EntryRevision {
                Name = "page"
            };

            Repository.FindFirstOrDefault(Arg.Any <EntryByNameQuery>()).Returns(entry);

            Controller.Page(entry.Name, (int?)null);

            Assert.IsNotNull(Controller.ViewData.Model);
            Assert.IsInstanceOf <PageModel>(Controller.ViewData.Model);

            var model = (PageModel)Controller.ViewData.Model;

            Assert.AreEqual(entry, model.Entry);
            Repository.Received().FindFirstOrDefault(Arg.Is <EntryByNameQuery>(q => q.PageName == entry.Name));
        }
Exemple #3
0
        public void WikiControllerTestsPageReturnsNotFoundForNewPageAndNotLoggedIn()
        {
            TestAuthenticationAndAuthorization.SetTestUserToCurrentPrincipal(false);

            var entries       = new List <EntryRevision>();
            var searchResults = new PagedResult <EntryRevision>(entries, 0, 0, 50);

            Repository.FindFirstOrDefault(Arg.Any <EntryByNameQuery>()).Returns(x => null);
            Repository.Find(Arg.Any <SwitchingSearchEntriesQuery>(), Arg.Any <int>(), Arg.Any <int>()).Returns(searchResults);

            var result = (ViewResult)Controller.Page("page", 0);

            Assert.AreEqual("Search", result.ViewName);
            Assert.IsNotNull(result.ViewData.Model);
            Assert.IsInstanceOf(typeof(SearchModel), result.ViewData.Model);

            var model = (SearchModel)result.ViewData.Model;

            Assert.AreSame(searchResults, model.Results);

            Repository.Received().Find(Arg.Is <SwitchingSearchEntriesQuery>(q => q.SearchText == "page"), Arg.Any <int>(), Arg.Any <int>());
            Repository.Received().FindFirstOrDefault(Arg.Is <EntryByNameAndRevisionQuery>(q => q.PageName == "page" && q.Revision == 0));
        }