示例#1
0
        public void WhenGetAccountFails_ShouldRedirectToBadRequest()
        {
            // Arrange
            var sut = new LevyEmployerTypeOnly();

            _accountApiClientMock
            .Setup(mock => mock.GetAccount(It.IsAny <string>()))
            .Throws(new Exception());

            // Act
            sut.OnActionExecuting(_filterContext);
            var result = _filterContext.Result as ViewResult;

            // Assert
            result.Should().NotBeNull();
            result.ViewName.Should().Be(ControllerConstants.BadRequestViewName);
        }
示例#2
0
        public void WhenLevyEmployer_ShouldAllowAccess()
        {
            // Arrange
            var sut = new LevyEmployerTypeOnly();

            _accountApiClientMock
            .Setup(mock => mock.GetAccount(It.IsAny <string>()))
            .ReturnsAsync(new AccountDetailViewModel {
                ApprenticeshipEmployerType = "Levy"
            });

            // Act
            sut.OnActionExecuting(_filterContext);
            var result = _filterContext.Result as ViewResult;

            // Assert
            _filterContext.Result.Should().BeNull();
        }
示例#3
0
        public void WhenNonLevyEmployer_ShouldDenyAccess()
        {
            // Arrange
            var sut = new LevyEmployerTypeOnly();

            _accountApiClientMock
            .Setup(mock => mock.GetAccount(It.IsAny <string>()))
            .ReturnsAsync(new AccountDetailViewModel {
                ApprenticeshipEmployerType = "NonLevy"
            });

            // Act
            sut.OnActionExecuting(_filterContext);
            var result = _filterContext.Result as RedirectToRouteResult;

            // Assert
            result.Should().NotBeNull();
            result.RouteValues["controller"].Should().Be("AccessDenied");
        }