public void ShouldReturnFramework()
        {
            // Assign
            var response  = new GetFrameworkResponse();
            var viewModel = new FrameworkViewModel();

            _mockMediator.Setup(m => m.Send(It.IsAny <GetFrameworkQuery>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(response);

            _mockMappingService.Setup(m => m.Map <GetFrameworkResponse, FrameworkViewModel>(response))
            .Returns(viewModel);

            // Act
            var result = _sut.Framework("1", "test").Result as ViewResult;

            // Assert
            _mockMediator.Verify(m => m.Send(It.IsAny <GetFrameworkQuery>(), It.IsAny <CancellationToken>()));
            _mockMappingService.Verify(m => m.Map <GetFrameworkResponse, FrameworkViewModel>(response));

            result.Model.Should().Be(viewModel);
        }
        public void FrameworkDetailPageWithErrorParameter(string hasErrorParmeter, bool expected)
        {
            var mockFrameworkRepository = new Mock <IGetFrameworks>();

            var stubFrameworkViewModel = new FrameworkViewModel
            {
                FrameworkId   = 123,
                Title         = "Title test",
                FrameworkName = "Framework name test",
                FrameworkCode = 321,
                Level         = 3,
                PathwayName   = "Pathway name test",
                PathwayCode   = 4
            };

            var framework = new Framework {
                Title = "Hello",
            };

            mockFrameworkRepository.Setup(x => x.GetFrameworkById(It.IsAny <int>())).Returns(framework);
            var mockMappingServices = new Mock <IMappingService>();

            mockMappingServices.Setup(
                x => x.Map <Framework, FrameworkViewModel>(It.IsAny <Framework>()))
            .Returns(stubFrameworkViewModel);

            var mockRequest = new Mock <HttpRequestBase>();

            mockRequest.Setup(x => x.UrlReferrer).Returns(new Uri("http://www.abba.co.uk"));

            var context = new Mock <HttpContextBase>();

            context.SetupGet(x => x.Request).Returns(mockRequest.Object);

            ApprenticeshipController controller = new ApprenticeshipController(null, null, mockFrameworkRepository.Object, null, mockMappingServices.Object, new Mock <IProfileAStep>().Object, null);

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);

            controller.Url = new UrlHelper(
                new RequestContext(context.Object, new RouteData()),
                new RouteCollection());

            var result = controller.Framework(1, hasErrorParmeter) as ViewResult;

            Assert.NotNull(result);
            var actual = ((FrameworkViewModel)result.Model).HasError;

            Assert.AreEqual(expected, actual);
        }
        public void FrameworkDetailPageStandardIsNull()
        {
            var mockFrameworkRepository = new Mock <IGetFrameworks>();

            var mockRequest = new Mock <HttpRequestBase>();

            mockRequest.Setup(x => x.UrlReferrer).Returns(new Uri("http://www.abba.co.uk"));
            var moqLogger = new Mock <ILog>();
            ApprenticeshipController controller = new ApprenticeshipController(null, null, mockFrameworkRepository.Object, moqLogger.Object, null, new Mock <IProfileAStep>().Object, null, null);

            HttpNotFoundResult result = (HttpNotFoundResult)controller.Framework(1);

            Assert.NotNull(result);
            Assert.AreEqual(404, result.StatusCode);
            Assert.AreEqual("Cannot find framework: 1", result.StatusDescription);
            moqLogger.Verify(m => m.Warn("404 - Cannot find framework: 1"));
        }