public void Arrange()
        {
            var distributedCacheMock = new Mock <IDistributedCache>();

            var certificatePrivateStandardCodeController =
                new CertificatePrivateStandardCodeController(MockLogger.Object,
                                                             MockHttpContextAccessor.Object,
                                                             MockOrganisationApiClient,
                                                             new CacheHelper(distributedCacheMock.Object),
                                                             MockCertificateApiClient,
                                                             MockSession.Object,
                                                             MockStandardServiceClient.Object
                                                             );

            var vm = new CertificateStandardCodeListViewModel
            {
                Id                   = Certificate.Id,
                FullName             = "James Corley",
                SelectedStandardCode = "93",
                IsPrivatelyFunded    = true
            };

            SetupSession();

            MockSession.Setup(q => q.Get("EndPointAsessorOrganisationId"))
            .Returns("EPA00001");

            certificatePrivateStandardCodeController.ModelState.AddModelError("", "Error");

            var result = certificatePrivateStandardCodeController.StandardCode(vm).GetAwaiter().GetResult();

            _result = result as ViewResult;
        }
Ejemplo n.º 2
0
        public void WhenInvalidModelContainsOneError()
        {
            var distributedCacheMock = new Mock <IDistributedCache>();

            var certificatePrivateStandardCodeController =
                new CertificatePrivateStandardCodeController(MockLogger.Object,
                                                             MockHttpContextAccessor.Object,
                                                             new CacheService(distributedCacheMock.Object),
                                                             MockApiClient,
                                                             MockStandardServiceClient.Object, MockOrganisationsApiClient);

            var vm = new CertificateStandardCodeListViewModel
            {
                Id                   = Certificate.Id,
                FullName             = "James Corley",
                SelectedStandardCode = "93",
                IsPrivatelyFunded    = true,
                ReasonForChange      = "Required reason for change"
            };

            MockSession.Setup(q => q.Get("EndPointAsessorOrganisationId"))
            .Returns("EPA00001");

            // 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
            certificatePrivateStandardCodeController.ModelState.AddModelError("", "Error");

            var result = certificatePrivateStandardCodeController.StandardCode(vm).GetAwaiter().GetResult();

            _result = result as ViewResult;
        }
        public void WhenValidModelContainsNoErrors()
        {
            var distributedCacheMock = new Mock <IDistributedCache>();

            var certificatePrivateStandardCodeController =
                new CertificatePrivateStandardCodeController(MockLogger.Object,
                                                             MockHttpContextAccessor.Object,
                                                             new CacheService(distributedCacheMock.Object),
                                                             MockApiClient,
                                                             MockStandardServiceClient.Object, MockOrganisationsApiClient
                                                             );

            var vm = new CertificateStandardCodeListViewModel
            {
                Id                   = Certificate.Id,
                FullName             = "James Corley",
                SelectedStandardCode = "93",
                IsPrivatelyFunded    = true,
                ReasonForChange      = "Required reason for change"
            };

            MockSession.Setup(q => q.Get("EndPointAsessorOrganisationId"))
            .Returns("EPA00001");

            var result = certificatePrivateStandardCodeController.StandardCode(vm).GetAwaiter().GetResult();

            _result = result as RedirectToActionResult;
        }
        public void Arrange()
        {
            Mock <IDistributedCache> mockDistributedCache = new Mock <IDistributedCache>();

            var certificatePrivateStandardCodeController =
                new CertificatePrivateStandardCodeController(MockLogger.Object,
                                                             MockHttpContextAccessor.Object,
                                                             new CacheService(mockDistributedCache.Object),
                                                             MockApiClient,
                                                             MockStandardServiceClient.Object, MockOrganisationsApiClient
                                                             );

            _result = certificatePrivateStandardCodeController.StandardCode(Certificate.Id, true).GetAwaiter().GetResult();

            var result = _result as ViewResult;

            _viewModelResponse = result.Model as CertificateStandardCodeListViewModel;
        }
        public void Arrange()
        {
            var mockDistributedCache = new Mock <IDistributedCache>();

            var certificatePrivateStandardCodeController =
                new CertificatePrivateStandardCodeController(MockLogger.Object,
                                                             MockHttpContextAccessor.Object,
                                                             MockOrganisationApiClient,
                                                             new CacheHelper(mockDistributedCache.Object),
                                                             MockCertificateApiClient,
                                                             MockSession.Object,
                                                             MockStandardServiceClient.Object
                                                             );

            SetupSession();
            AddRedirectCheck();

            var result = certificatePrivateStandardCodeController.StandardCode(false).GetAwaiter().GetResult();

            _result = result as ViewResult;
        }
        public void Arrange()
        {
            Mock <IDistributedCache> mockDistributedCache = new Mock <IDistributedCache>();

            var certificatePrivateStandardCodeController =
                new CertificatePrivateStandardCodeController(MockLogger.Object,
                                                             MockHttpContextAccessor.Object,
                                                             MockOrganisationApiClient,
                                                             new CacheHelper(mockDistributedCache.Object),
                                                             MockCertificateApiClient,
                                                             MockSession.Object,
                                                             MockStandardServiceClient.Object
                                                             );

            MockSession.Setup(q => q.Get("EndPointAsessorOrganisationId"))
            .Returns("EPA00001");

            var result = certificatePrivateStandardCodeController.StandardCode(false).GetAwaiter().GetResult();

            _result = result as RedirectToActionResult;
        }