public async Task RequestAccessPost()
        {
            var providerCode = "PROVIDERCODE";
            var viewModel    = new RequestAccessViewModel {
                FirstName = "FirstName", LastName = "LastName"
            };
            var tempKey = "RequestAccess_To_Name";

            var apiMock = new Mock <IManageApi>();

            var tempDataMock = new Mock <ITempDataDictionary>();

            var frontendUrlMock = new Mock <IFrontendUrlService>();

            var controller = new OrganisationController(apiMock.Object, frontendUrlMock.Object);

            controller.TempData = tempDataMock.Object;

            var result = await controller.RequestAccessPost(providerCode, viewModel);

            apiMock.Verify(x => x.GetProviderSummaries(), Times.Never);
            apiMock.Verify(x => x.CreateAccessRequest(It.IsAny <GovUk.Education.ManageCourses.Api.Model.AccessRequest>()), Times.Once);

            tempDataMock.Verify(x => x.Add(tempKey, $"{viewModel.FirstName} {viewModel.LastName}"));

            var actionResult = result as RedirectToActionResult;

            Assert.IsNotNull(actionResult);
            Assert.AreEqual("Show", actionResult.ActionName);
            Assert.AreEqual("Organisation", actionResult.ControllerName);
            Assert.AreEqual(providerCode, actionResult.RouteValues[providerCode]);
        }
        public async Task RequestAccessPost_invalid()
        {
            var providerCode     = "PROVIDERCODE";
            var organisationName = "organisationName";

            var orgs = new List <ProviderSummary>
            {
                new ProviderSummary
                {
                    ProviderCode = providerCode,
                    ProviderName = organisationName
                }
            };

            var apiMock = new Mock <IManageApi>();

            apiMock.Setup(x => x.GetProviderSummaries())
            .ReturnsAsync(orgs);

            var frontendUrlMock = new Mock <IFrontendUrlService>();

            var controller = new OrganisationController(apiMock.Object, frontendUrlMock.Object);

            controller.ModelState.AddModelError("you", "failed");
            var result = await controller.RequestAccessPost(providerCode, new RequestAccessViewModel());

            var viewResult = result as ViewResult;

            Assert.IsNotNull(viewResult);
            var model = viewResult.ViewData.Model as RequestAccessViewModel;

            Assert.AreEqual(providerCode, controller.ViewBag.ProviderCode);
        }