public void WhenNoValidValuesAreProvided() { var mockApprenticeshipViewModelFactory = new Mock <IApprenticeshipViewModelFactory>(); mockApprenticeshipViewModelFactory.Setup(m => m.GetFrameworkProvidersViewModel(It.IsAny <int>(), It.IsAny <UrlHelper>())).Returns(new ProviderSearchViewModel()); var controller = new ApprenticeshipController(null, null, null, null, null, null, null, mockApprenticeshipViewModelFactory.Object); var result = controller.SearchForProviders(null, null, null) as HttpStatusCodeResult; result.StatusCode.Should().Be(400); }
public void SearchForProvidersWithNoErrors() { var mockApprenticeshipViewModelFactory = new Mock <IApprenticeshipViewModelFactory>(); mockApprenticeshipViewModelFactory.Setup(m => m.GetStandardViewModel(It.IsAny <int>(), It.IsAny <UrlHelper>())).Returns(new ProviderSearchViewModel()); var controller = new ApprenticeshipController(null, null, null, null, null, null, null, mockApprenticeshipViewModelFactory.Object); var result = controller.SearchForProviders(1, null, null) as ViewResult; var viewModel = result?.Model as ProviderSearchViewModel; viewModel?.HasError.Should().BeFalse(); }
public void SearchForProvidersActionWithFrameworIdParameter() { var mockApprenticeshipViewModelFactory = new Mock <IApprenticeshipViewModelFactory>(); mockApprenticeshipViewModelFactory.Setup(m => m.GetFrameworkProvidersViewModel(It.IsAny <int>(), It.IsAny <UrlHelper>())).Returns(new ProviderSearchViewModel()); var controller = new ApprenticeshipController(null, null, null, null, null, null, null, mockApprenticeshipViewModelFactory.Object); controller.SearchForProviders(null, 12, null); mockApprenticeshipViewModelFactory.Verify(m => m.GetFrameworkProvidersViewModel(It.IsAny <int>(), It.IsAny <UrlHelper>()), Times.Once); mockApprenticeshipViewModelFactory.Verify(m => m.GetStandardViewModel(It.IsAny <int>(), It.IsAny <UrlHelper>()), Times.Never); }