public void WhenInvalidModelContainsOneError()
        {
            var certificatePrivateProviderUkprnController =
                new CertificatePrivateProviderUkprnController(MockLogger.Object,
                                                              MockHttpContextAccessor.Object,
                                                              MockApiClient
                                                              );

            var vm = new CertificateUkprnViewModel
            {
                Id                = Certificate.Id,
                Ukprn             = "",
                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
            certificatePrivateProviderUkprnController.ModelState.AddModelError("", "Error");

            var result = certificatePrivateProviderUkprnController.Ukprn(vm).GetAwaiter().GetResult();

            _result = result as ViewResult;
        }
        public void Arrange()
        {
            var certificatePrivateProviderUkprnController =
                new CertificatePrivateProviderUkprnController(MockLogger.Object,
                                                              MockHttpContextAccessor.Object,
                                                              MockCertificateApiClient,
                                                              MockSession.Object
                                                              );

            var roatpApiClient = new Mock <IRoatpApiClient>();

            SetupSession();

            var mockStringLocaliserBuildernew = new MockStringLocaliserBuilder();

            var localiser = mockStringLocaliserBuildernew
                            .WithKey(ResourceMessageName.NoAssesmentProviderFound)
                            .WithKeyValue("100000000")
                            .Build <CertificateUkprnViewModelValidator>();

            var certificateUkprnViewModelValidator
                = new CertificateUkprnViewModelValidator(localiser.Object,
                                                         roatpApiClient.Object);

            var vm = new CertificateUkprnViewModel
            {
                Id                = Certificate.Id,
                Ukprn             = "AAAAAA",
                IsPrivatelyFunded = true
            };

            _validationResult = certificateUkprnViewModelValidator.Validate(vm);
        }
        public void Arrange()
        {
            var certificatePrivateProviderUkprnController =
                new CertificatePrivateProviderUkprnController(MockLogger.Object,
                                                              MockHttpContextAccessor.Object,
                                                              MockCertificateApiClient,
                                                              MockSession.Object
                                                              );

            var result = certificatePrivateProviderUkprnController.Ukprn(false).GetAwaiter().GetResult();

            _result = result as RedirectToActionResult;
        }
Example #4
0
        public void Arrange()
        {
            var certificatePrivateProviderUkprnController =
                new CertificatePrivateProviderUkprnController(MockLogger.Object,
                                                              MockHttpContextAccessor.Object,
                                                              MockApiClient
                                                              );


            _result = certificatePrivateProviderUkprnController.Ukprn(Certificate.Id, true).GetAwaiter().GetResult();

            var result = _result as ViewResult;

            _viewModelResponse = result.Model as CertificateUkprnViewModel;
        }
        public void WhenValidModelContainsNoErrors()
        {
            var certificatePrivateProviderUkprnController =
                new CertificatePrivateProviderUkprnController(MockLogger.Object,
                                                              MockHttpContextAccessor.Object,
                                                              MockApiClient
                                                              );

            var vm = new CertificateUkprnViewModel
            {
                Id                = Certificate.Id,
                Ukprn             = "10000008",
                IsPrivatelyFunded = true,
                ReasonForChange   = "Required reason for change"
            };

            var result = certificatePrivateProviderUkprnController.Ukprn(vm).GetAwaiter().GetResult();

            _result = result as RedirectToActionResult;
        }
        public void Arrange()
        {
            var certificatePrivateProviderUkprnController =
                new CertificatePrivateProviderUkprnController(MockLogger.Object,
                                                              MockHttpContextAccessor.Object,
                                                              MockCertificateApiClient,
                                                              MockSession.Object
                                                              );

            var vm = new CertificateUkprnViewModel
            {
                Id                = Certificate.Id,
                Ukprn             = "10000008",
                IsPrivatelyFunded = true
            };

            SetupSession();

            var result = certificatePrivateProviderUkprnController.Ukprn(vm).GetAwaiter().GetResult();

            _result = result as RedirectToActionResult;
        }