Пример #1
0
 private static async Task <IActionResult> RunControllerAction(PagesController controller, int soc, string actionName)
 {
     return(actionName switch
     {
         nameof(PagesController.Document) => await controller.Document(soc).ConfigureAwait(false),
         _ => await controller.Index().ConfigureAwait(false),
     });
Пример #2
0
        protected override void OnStart()
        {
            base.OnStart();

            if (Renderer != null)
            {
                Renderer.material.mainTexture = Movie.OutputTexture;
            }

            Movie          = GetComponent <AVProWindowsMediaMovie>();
            _image.texture = Movie.OutputTexture;


            _page = GetComponent <Page.Page>();

            _pagesController = _bootstrap.GetController(ControllerTypes.Page) as PagesController;

            _id   = _page.Id;
            _type = _page.Type;

            _pagesController.NextPage     += CheckPage;
            _pagesController.PreviousPage += CheckPage;
            _pagesController.OpenPage     += CheckPage;
            _pagesController.OpenPageType += CheckPage;
        }
Пример #3
0
        public PagesControllerTests()
        {
            _fixture = new Fixture();

            _pageRepositoryMock       = Substitute.For <IPageRepository>();
            _viewObjectsConverterMock = Substitute.For <IPageObjectsConverter>();

            _viewObjectsConverterMock
            .ConvertToPageResponse(Arg.Any <Page>())
            .Returns(c =>
            {
                var page = c.Arg <Page>();
                return(new PageResponse()
                {
                    Id = page.Id, Title = page.Title
                });
            });

            _viewObjectsConverterMock
            .ConvertToPage(Arg.Any <PageRequest>())
            .Returns(c =>
            {
                var pageRequest = c.Arg <PageRequest>();
                return(new Page()
                {
                    Id = pageRequest.Id,
                    Title = pageRequest.Title
                });
            });

            _pagesController = new PagesController(_pageRepositoryMock, _viewObjectsConverterMock);
        }
        public void TestEditPageIsCalled()
        {
            // Arrange - create the mock repo and manager
            Page suprise = new Page()
            {
                Id = 1, Page_Name = "TheSurpriseModified", Title = "Hallo123", Content = "Test321"
            };

            var repo = new Mock <IPageRepository>();

            repo.Setup(x => x.GetPage(1)).Returns(suprise);
            repo.Setup(x => x.EditPage(1, suprise));

            var manager = new PageManager(repo.Object);

            // Arrange - create a controller
            PagesController target = new PagesController(manager);

            // Modify page
            suprise.Title = "Testing";

            // Action
            var model = (target.Edit(1) as ViewResult).ViewData.Model as PageViewModel;

            // Assert
            Assert.NotNull(model);
            Assert.Equal("Testing", model.Title);
        }
Пример #5
0
        public void ShouldKnowHowToListAllPages()
        {
            var repository = new Mock <Repository>();
            var savedPages = new List <StaticPage>
            {
                new StaticPage {
                    Id = 1, Title = "test title", Content = "Hello\n=====\nWorld"
                },
                new StaticPage {
                    Id = 2, Title = "test title2", Content = "Hello\n=====\nAnother World"
                }
            };
            var savedPageInformations = new List <StaticPageInformation>
            {
                new StaticPageInformation {
                    Model = savedPages[0]
                },
                new StaticPageInformation {
                    Model = savedPages[1]
                }
            };

            repository.Setup(repo => repo.Search <StaticPage>(It.IsAny <Expression <Func <StaticPage, bool> > >(), It.IsAny <int>(), It.IsAny <int>())).Returns(savedPages);
            repository.Setup(repo => repo.Search <StaticPage>(It.IsAny <Expression <Func <StaticPage, bool> > >())).Returns(savedPages);
            var controller = new PagesController(repository.Object);
            var result     = controller.List();

            repository.Verify(it => it.Search <StaticPage>(It.IsAny <Expression <Func <StaticPage, bool> > >(), It.IsAny <int>(), It.IsAny <int>()), Times.Once());
            Assert.AreEqual(savedPageInformations[0].Model, ((PagedList.IPagedList <StaticPageInformation>)result.Model)[0].Model);
            Assert.AreEqual(savedPageInformations[1].Model, ((PagedList.IPagedList <StaticPageInformation>)result.Model)[1].Model);
        }
Пример #6
0
        void ReleaseDesignerOutlets()
        {
            if (BarItemRestore != null)
            {
                BarItemRestore.Dispose();
                BarItemRestore = null;
            }

            if (BarItemStart != null)
            {
                BarItemStart.Dispose();
                BarItemStart = null;
            }

            if (BarItemStore != null)
            {
                BarItemStore.Dispose();
                BarItemStore = null;
            }

            if (PagesController != null)
            {
                PagesController.Dispose();
                PagesController = null;
            }

            if (PagesView != null)
            {
                PagesView.Dispose();
                PagesView = null;
            }
        }
Пример #7
0
        protected override void OnStart()
        {
            base.OnStart();

            _timeController.Timeout += GoToPage;
            _pagesController         = _controller as PagesController;
        }
        protected override void OnStart()
        {
            page = GetComponent <Page>();

            _controller.OnGameStart += OnGameStart;
            _controller.OnGameEnd   += OnGameEnd;
            _pagesController         = _bootstrap.GetController(ControllerTypes.Page) as PagesController;
        }
Пример #9
0
        public void ShouldDisplayFormForNewPage()
        {
            var repository = new Mock <Repository>();
            var controller = new PagesController(repository.Object);
            var result     = (ViewResult)controller.Create();

            Assert.AreEqual("Create", result.ViewName);
        }
Пример #10
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _pageRepositoryMock = _container.PageRepository;
            _pageService        = _container.PageService;

            _pagesController = new PagesController(_pageService);
        }
        protected override void OnStart()
        {
            base.OnStart();

            _pagesController = _bootstrap.GetController(ControllerTypes.Page) as PagesController;

            _quizController = _controller as QuizController;
            _quizController.OnAnswerFeedback += OnAnswerFeedback;
            _quizController.Reset            += OnReset;
        }
Пример #12
0
        public void ShouldKnowHowToDeletePage()
        {
            var id         = 1;
            var repository = new Mock <Repository>();
            var controller = new PagesController(repository.Object);
            var result     = (RedirectToRouteResult)controller.Delete(id);

            repository.Verify(it => it.Delete <StaticPage>(id), Times.Once());
            Assert.AreEqual("List", result.RouteValues["action"]);
        }
		public void Contact_ViewResult_Should_Have_The_Right_Title ()
		{
			string intendedTitle = "Squarker | Contact";
			var pagesController = new PagesController();
			
			var result = pagesController.Contact() as ViewResult;
			
			string actualTitle = ApplicationHelper.RenderTitle(result.ViewData);
			
			Assert.AreEqual(intendedTitle, actualTitle, "Contact page title was incorrect");
		}
Пример #14
0
        protected override void OnStart()
        {
            _pagesController = _bootstrap.GetController(ControllerTypes.Page) as PagesController;

            var page = GetComponent <Page>();

            _id = page.Id;

            _controller.OnGameEnd  += PassPage;
            _pagesController.Reset += StopCoroutines;
        }
Пример #15
0
        protected override void OnStart()
        {
            _pagesController = _controller as PagesController;

            _pagesController.NextPage     += CheckPage;
            _pagesController.PreviousPage += CheckPage;
            _pagesController.OpenPage     += CheckPage;
            _pagesController.OpenPageType += CheckPage;

            _bootstrap.AppStarted += CheckPage;
        }
		public void About_Action_Should_Return_About_View()
		{
			//Arrange
			var pagesController = new PagesController();
			
			//Act
			var result = pagesController.About() as ViewResult;
			
			//Assert
			Assert.IsNotNull(result, "Should have returned a ViewResult");
			Assert.AreEqual("About", result.ViewName, "View should have been About");
		}
Пример #17
0
        public void Setup()
        {
            _container = new MocksAndStubsContainer();

            _applicationSettings = _container.ApplicationSettings;
            _userContext         = _container.UserContext;
            _userService         = _container.UserService;
            _pageRepositoryMock  = _container.PageRepository;
            _pageService         = _container.PageService;

            _pagesController = new PagesController(_pageService, _applicationSettings, _userService, _userContext);
        }
Пример #18
0
        protected override void OnStart()
        {
            _pagesController = _bootstrap.GetController(ControllerTypes.Page) as PagesController;
            _dynamicQuiz     = _controller as DynamicQuizPointBased;

            var page = GetComponent <Page.Page>();

            _id = page.Id;

            _dynamicQuiz.OnReceiveAnswer += PassPage;

            _pagesController.Reset += StopCoroutines;
        }
Пример #19
0
 private static async Task <IActionResult> RunControllerAction(PagesController controller, PageRequestModel pageRequestModel, string actionName)
 {
     return(actionName switch
     {
         nameof(PagesController.HtmlHead) => await controller.HtmlHead(pageRequestModel).ConfigureAwait(false),
         nameof(PagesController.Breadcrumb) => await controller.Breadcrumb(pageRequestModel).ConfigureAwait(false),
         nameof(PagesController.BodyTop) => controller.BodyTop(pageRequestModel),
         nameof(PagesController.HeroBanner) => await controller.HeroBanner(pageRequestModel).ConfigureAwait(false),
         nameof(PagesController.SidebarRight) => controller.SidebarRight(pageRequestModel),
         nameof(PagesController.SidebarLeft) => controller.SidebarLeft(pageRequestModel),
         nameof(PagesController.BodyFooter) => controller.BodyFooter(pageRequestModel),
         _ => await controller.Body(pageRequestModel).ConfigureAwait(false),
     });
Пример #20
0
        public void Init()
        {
            _ctrl = new PagesController(new FakePageRepository());

            var config = new HttpConfiguration();
            var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/be/api");
            var route = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}");
            var routeData = new HttpRouteData(route, new HttpRouteValueDictionary { { "controller", "pages" } });

            _ctrl.ControllerContext = new HttpControllerContext(config, routeData, request);
            _ctrl.Request = request;
            _ctrl.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
        }
Пример #21
0
        public void ShouldNotStorePageWhenContentIsInvalid()
        {
            var repository    = new Mock <Repository>();
            var submittedPage = new StaticPage {
                Title = "test title", Content = ""
            };

            repository.Setup(repo => repo.Create(submittedPage)).Returns(submittedPage);

            var controller = new PagesController(repository.Object);

            ValidateViewModel(submittedPage, controller);
            Assert.IsFalse(controller.ModelState.IsValid);
        }
        private static async Task <IActionResult> RunControllerAction(PagesController controller, string category, string article, string actionName)
        {
            switch (actionName)
            {
            case "Head":
                return(await controller.Head(category, article).ConfigureAwait(false));

            case "Breadcrumb":
                return(await controller.Breadcrumb(category, article).ConfigureAwait(false));

            default:
                return(await controller.Body(category, article).ConfigureAwait(false));
            }
        }
Пример #23
0
        protected override void OnStart()
        {
            _pagesController = _controller as PagesController;

            var page = GetComponent <Page.Page>();

            _id   = page.Id;
            _type = page.Type;

            _pagesController.NextPage     += CheckPage;
            _pagesController.PreviousPage += CheckPage;
            _pagesController.OpenPage     += CheckPage;
            _pagesController.OpenPageType += CheckPage;
        }
Пример #24
0
        public void ShouldKnowHowToDisplayAPage()
        {
            var id         = 12;
            var repository = new Mock <Repository>();
            var savedPage  = new StaticPage {
                Id = id, Title = "test title", Content = "some content"
            };

            repository.Setup(repo => repo.Get <StaticPage>(id)).Returns(savedPage);
            var controller = new PagesController(repository.Object);
            var result     = controller.Details(id);

            repository.Verify(it => it.Get <StaticPage>(id), Times.Once());
            Assert.AreEqual(id, ((StaticPageInformation)result.Model).Model.Id);
        }
        public void Init()
        {
            _ctrl = new PagesController(new FakePageRepository());

            var config    = new HttpConfiguration();
            var request   = new HttpRequestMessage(HttpMethod.Post, "http://localhost/be/api");
            var route     = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}");
            var routeData = new HttpRouteData(route, new HttpRouteValueDictionary {
                { "controller", "pages" }
            });

            _ctrl.ControllerContext = new HttpControllerContext(config, routeData, request);
            _ctrl.Request           = request;
            _ctrl.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
        }
Пример #26
0
        protected override void OnStart()
        {
            _pagesController = _controller as PagesController;

            _routineIsRunning = false;

            var page = GetComponent <Page>();

            _id   = page.Id;
            _type = page.Type;

            _timeController.Timeout += CheckPage;

            _pagesController.Reset += StopCoroutines;
        }
Пример #27
0
        public void ShouldKnowHowToUpdateAPage()
        {
            var repository   = new Mock <Repository>();
            var existingPage = new StaticPage {
                Id = 1, Title = "Derping for dummies."
            };

            repository.Setup(repo => repo.Edit(existingPage));
            var pagesController = new PagesController(repository.Object);
            var result          = pagesController.Edit(new StaticPageInformation {
                Model = existingPage
            });

            Assert.AreEqual(existingPage.Id, result.RouteValues["id"]);
            repository.Verify(repo => repo.Edit(existingPage), Times.Once());
        }
Пример #28
0
        public void ShouldKnowHowToRenderAnEditPage()
        {
            var repositoryMock = new Mock <Repository>();
            var page           = new StaticPage {
                Id = 1, Title = "The Page"
            };

            repositoryMock.Setup(repo => repo.Get <StaticPage>(page.Id)).Returns(page);
            var pagesController = new PagesController(repositoryMock.Object);

            var result      = pagesController.Edit(page.Id);
            var actualModel = (StaticPageInformation)result.Model;

            Assert.AreEqual(page.Title, actualModel.Model.Title);
            repositoryMock.Verify(repo => repo.Get <StaticPage>(1), Times.Once());
        }
        protected PagesController BuildPagesController(string mediaTypeName)
        {
            var httpContext = new DefaultHttpContext();

            httpContext.Request.Headers[HeaderNames.Accept] = mediaTypeName;

            var controller = new PagesController(FakeLogger, FakeMapper, FakeJobGroupDocumentService, FakeSharedContentDocumentService)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = httpContext,
                },
            };

            return(controller);
        }
Пример #30
0
        public void ShouldKnowToRenderThePageContentAsMarkdown()
        {
            var id         = 12;
            var repository = new Mock <Repository>();
            var markdown   = new Markdown();
            var savedPage  = new StaticPage {
                Id = id, Title = "test title", Content = "Hello\n=====\nWorld"
            };

            repository.Setup(repo => repo.Get <StaticPage>(id)).Returns(savedPage);
            var transformedContent = markdown.Transform(savedPage.Content);
            var controller         = new PagesController(repository.Object);
            var result             = controller.Details(id);

            Assert.AreEqual(transformedContent, ((StaticPageInformation)result.Model).Content);
        }
        protected PagesController BuildPagesController(string mediaTypeName)
        {
            var httpContext = new DefaultHttpContext();

            httpContext.Request.Headers[HeaderNames.Accept] = mediaTypeName;

            var controller = new PagesController(Logger, FakeSessionStateService, FakeConfigurationSetDocumentService, FakeMapper)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = httpContext,
                },
            };

            return(controller);
        }
        protected PagesController BuildPagesController(string mediaTypeName)
        {
            var httpContext = new DefaultHttpContext();

            httpContext.Request.Headers[HeaderNames.Accept] = mediaTypeName;

            var controller = new PagesController(Logger, FakeJobCategoryContentPageService, FakeJobProfileContentPageService, FakeMapper)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = httpContext,
                },
            };

            return(controller);
        }
Пример #33
0
        public void ShouldDisplayOnlyDraftPagesCreatedByCurrentUserWhenListingDraftPages()
        {
            string userName = "******";

            UsingSession((session) =>
            {
                var repository = new Repository(session);
                var controller = new PagesController(repository);
                controller.Create(new StaticPageInformation()
                {
                    Model = new StaticPage {
                        Id = 1, Title = "Draft Page", Content = "Hello\n=====\nWorld", IsDraft = true, Creator = userName
                    }
                });
                controller.Create(new StaticPageInformation()
                {
                    Model = new StaticPage {
                        Id = 2, Title = "Draft Page 2", Content = "Hello\n=====\nAnother World", IsDraft = true, Creator = userName
                    }
                });
                controller.Create(new StaticPageInformation()
                {
                    Model = new StaticPage {
                        Id = 3, Title = "Draft Page 3", Content = "Hello\n=====\nI'm a draft", IsDraft = true, Creator = "anotherUser"
                    }
                });
            });

            UsingSession((session) =>
            {
                WaitForTheLastWrite <StaticPage>(session);

                var httpContextStub = new Mock <HttpContextBase>
                {
                    DefaultValue = DefaultValue.Mock
                };
                var user = Mock.Get(httpContextStub.Object.User);
                user.Setup(u => u.Identity.Name).Returns(userName);

                var controller = new PagesController(new Repository(session));
                controller.ControllerContext = new ControllerContext(httpContextStub.Object, new RouteData(), controller);
                var result = controller.List(excludeDraft: false);
                var pages  = (PagedList.IPagedList <StaticPageInformation>)result.Model;

                Assert.AreEqual(2, pages.Count);
            });
        }