Пример #1
0
        public void IndexWithUrlNameTest(string urlName, bool validJobProfile)
        {
            SetupCallsAndFakes(validJobProfile);

            //Act
            var jobprofilehtbController    = new JobProfileHowToBecomeController(webAppContextFake, jobProfileRepositoryFake, applicationLoggerFake, sitefinityPageFake, mapper);
            var indexWithUrlNameMethodCall = jobprofilehtbController.WithCallTo(c => c.Index(urlName));

            //Assert
            if (validJobProfile)
            {
                indexWithUrlNameMethodCall
                .ShouldRenderDefaultView()
                .WithModel <JobProfileHowToBecomeViewModel>(vm =>
                {
                    AssertViewModelProperties(vm, jobprofilehtbController, validJobProfile);
                })
                .AndNoModelErrors();
                A.CallTo(() => jobProfileRepositoryFake.GetByUrlName(A <string> ._)).MustHaveHappened();
            }
            else
            {
                indexWithUrlNameMethodCall.ShouldGiveHttpStatus(404);
            }
        }
Пример #2
0
        public void IndexTest(bool validJobProfile, bool inContentAuthoringSite, bool isContentPreviewMode)
        {
            //Assign
            SetupCallsAndFakes(validJobProfile, inContentAuthoringSite, isContentPreviewMode);

            //Act
            var jobprofilehtbController = new JobProfileHowToBecomeController(webAppContextFake, jobProfileRepositoryFake, applicationLoggerFake, sitefinityPageFake, mapper);
            var indexMethodCall         = jobprofilehtbController.WithCallTo(c => c.Index());

            //Assert
            if (inContentAuthoringSite)
            {
                indexMethodCall
                .ShouldRenderDefaultView()
                .WithModel <JobProfileHowToBecomeViewModel>(vm =>
                {
                    AssertViewModelProperties(vm, jobprofilehtbController, validJobProfile);
                })
                .AndNoModelErrors();

                if (!isContentPreviewMode)
                {
                    A.CallTo(() => jobProfileRepositoryFake.GetByUrlName(A <string> ._)).MustHaveHappened();
                }
                else
                {
                    A.CallTo(() => jobProfileRepositoryFake.GetByUrlNameForPreview(A <string> ._)).MustHaveHappened();
                }
            }
            else
            {
                indexMethodCall.ShouldRedirectTo("\\");
            }
        }