public void WhenInvalidModelContainsOneError() { var mockStringLocaliserBuildernew = new MockStringLocaliserBuilder(); CertificateLearnerStartDateViewModelValidator validator = new CertificateLearnerStartDateViewModelValidator(); var certificatePrivateLearnerStartDateController = new CertificatePrivateLearnerStartDateController(MockLogger.Object, MockHttpContextAccessor.Object, MockApiClient, validator ); var vm = new CertificateLearnerStartDateViewModel { Id = Certificate.Id, FullName = "James Corley", Day = "12", Month = "12", Year = "2017", IsPrivatelyFunded = true, ReasonForChange = "Required reason for change" }; // view model validation errors will not be trigged as they are attached via fluent // validation and these are not connected in tests however this test is actually testing // the correct view is returned so the actual error is irrelevant and can be forced certificatePrivateLearnerStartDateController.ModelState.AddModelError("", "Error"); var result = certificatePrivateLearnerStartDateController.LearnerStartDate(vm).GetAwaiter().GetResult(); _result = result as ViewResult; }
public void Arrange() { MockStringLocaliserBuilder mockStringLocaliserBuilder; mockStringLocaliserBuilder = new MockStringLocaliserBuilder(); Mock <IStringLocalizer <CertificateLearnerStartDateViewModelValidator> > mockLocaliser = new Mock <IStringLocalizer <CertificateLearnerStartDateViewModelValidator> >(); mockLocaliser = mockStringLocaliserBuilder .WithKey("XXXX") .WithKeyValue("100000000") .Build <CertificateLearnerStartDateViewModelValidator>(); var certificateLearnerStartDateViewModelValidator = new CertificateLearnerStartDateViewModelValidator(mockLocaliser.Object); var certificatePrivateLearnerStartDateController = new CertificatePrivateLearnerStartDateController(MockLogger.Object, MockHttpContextAccessor.Object, MockCertificateApiClient, certificateLearnerStartDateViewModelValidator, MockSession.Object ); SetupSession(); _result = certificatePrivateLearnerStartDateController.LearnerStartDate(false).GetAwaiter().GetResult(); var result = _result as ViewResult; _viewModelResponse = result.Model as CertificateLearnerStartDateViewModel; }
public void WhenTheModelIsValid() { var mockStringLocaliserBuildernew = new MockStringLocaliserBuilder(); var validator = new CertificateLearnerStartDateViewModelValidator(); var certificatePrivateLearnerStartDateController = new CertificatePrivateLearnerStartDateController(MockLogger.Object, MockHttpContextAccessor.Object, MockApiClient, validator ); var vm = new CertificateLearnerStartDateViewModel { Id = Certificate.Id, FullName = "James Corley", Day = "12", Month = "12", Year = "2017", IsPrivatelyFunded = true, ReasonForChange = "Required reason for change" }; var result = certificatePrivateLearnerStartDateController.LearnerStartDate(vm).GetAwaiter().GetResult(); _result = result as RedirectToActionResult; }
public void Arrange() { var mockStringLocaliserBuildernew = new MockStringLocaliserBuilder(); var localiser = mockStringLocaliserBuildernew .WithKey(ResourceMessageName.NoAssesmentProviderFound) .WithKeyValue("100000000") .Build <CertificateLearnerStartDateViewModelValidator>(); CertificateLearnerStartDateViewModelValidator validator = new CertificateLearnerStartDateViewModelValidator(localiser.Object); var certificatePrivateLearnerStartDateController = new CertificatePrivateLearnerStartDateController(MockLogger.Object, MockHttpContextAccessor.Object, MockCertificateApiClient, validator, MockSession.Object ); var vm = new CertificateLearnerStartDateViewModel { Id = Certificate.Id, FullName = "James Corley", Day = "12", Month = "12", Year = "2017", IsPrivatelyFunded = true }; SetupSession(); AddRedirectCheck(); var result = certificatePrivateLearnerStartDateController.LearnerStartDate(vm).GetAwaiter().GetResult(); _result = result as RedirectToActionResult; }