public async Task <ActionResult> AuthorisationRequired(Guid pcsId) { using (IWeeeClient client = apiClient()) { SchemeStatus status = await client.SendAsync(User.GetAccessToken(), new GetSchemeStatus(pcsId)); if (status == SchemeStatus.Approved) { return(RedirectToAction("Index", new { pcsId })); } string userIdString = User.GetUserId(); bool showLinkToSelectOrganisation = false; if (userIdString != null) { Guid userId = new Guid(userIdString); int activeUserCompleteOrganisationCount = await cache.FetchUserActiveCompleteOrganisationCount(userId); showLinkToSelectOrganisation = (activeUserCompleteOrganisationCount > 1); } await SetBreadcrumb(pcsId); return(View(new AuthorizationRequiredViewModel { Status = status, ShowLinkToSelectOrganisation = showLinkToSelectOrganisation })); } }
public async Task <ActionResult> FetchDetails(string registrationNumber, int complianceYear) { if (Request != null && !Request.IsAjaxRequest()) { throw new InvalidOperationException(); } if (!ModelState.IsValid) { return(Json(null, JsonRequestBehavior.AllowGet)); } using (IWeeeClient client = apiClient()) { await SetBreadcrumb(); GetProducerDetails request = new GetProducerDetails() { RegistrationNumber = registrationNumber, ComplianceYear = complianceYear }; ProducerDetails producerDetails = await client.SendAsync(User.GetAccessToken(), request); return(PartialView("_detailsResults", producerDetails)); } }
public async Task GetDownloadInvoiceFiles_ForEngland_CallsApiAndReturnsFileResult() { // Arrange Guid invoiceRunId = new Guid("ADED8BDE-CF03-4696-B972-DDAB9306A6DD"); FileInfo fileInfo = new FileInfo("Test file.zip", A.Dummy <byte[]>()); IWeeeClient weeeClient = A.Fake <IWeeeClient>(); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <FetchInvoiceRunIbisZipFile> ._)) .WhenArgumentsMatch(a => a.Get <FetchInvoiceRunIbisZipFile>("request").InvoiceRunId == invoiceRunId) .Returns(fileInfo); ChargeController controller = new ChargeController( A.Dummy <IAppConfiguration>(), A.Dummy <BreadcrumbService>(), () => weeeClient); // Act ActionResult result = await controller.DownloadInvoiceFiles( CompetentAuthority.England, invoiceRunId); // Assert FileResult fileResult = result as FileResult; Assert.NotNull(fileResult); Assert.Equal("Test file.zip", fileResult.FileDownloadName); Assert.Equal("text/plain", fileResult.ContentType); }
public AccountControllerTests() { apiClient = A.Fake<IWeeeClient>(); unauthenticatedUserClient = A.Fake<IUnauthenticatedUser>(); weeeAuthorization = A.Fake<IWeeeAuthorization>(); externalRouteService = A.Fake<IExternalRouteService>(); }
public async Task GetDownloadInvoiceFiles_ForDevolvedAuthority_ThowsInvalidOperationException() { // Arrange Guid invoiceRunId = new Guid("ADED8BDE-CF03-4696-B972-DDAB9306A6DD"); FileInfo fileInfo = new FileInfo("Test file.zip", A.Dummy <byte[]>()); IWeeeClient weeeClient = A.Fake <IWeeeClient>(); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <FetchInvoiceRunIbisZipFile> ._)) .WhenArgumentsMatch(a => a.Get <FetchInvoiceRunIbisZipFile>("request").InvoiceRunId == invoiceRunId) .Returns(fileInfo); ChargeController controller = new ChargeController( A.Dummy <IAppConfiguration>(), A.Dummy <BreadcrumbService>(), () => weeeClient); // Act Func <Task <ActionResult> > testCode = async() => await controller.DownloadInvoiceFiles( CompetentAuthority.Scotland, invoiceRunId); // Assert await Assert.ThrowsAsync <InvalidOperationException>(testCode); }
public async Task <ActionResult> ManagePendingCharges(CompetentAuthority authority, FormCollection formCollection) { using (IWeeeClient client = weeeClient()) { IssuePendingCharges request = new IssuePendingCharges(authority); IssuePendingChargesResult result = await client.SendAsync(User.GetAccessToken(), request); if (Request.IsAjaxRequest()) { var jsonResult = new { Success = result.Errors.Count == 0, InvoiceRunId = result.InvoiceRunId, Errors = result.Errors }; return(Json(jsonResult)); } else { if (result.Errors.Count == 0) { return(RedirectToAction("ChargesSuccessfullyIssued", new { authority, id = result.InvoiceRunId.Value })); } else { return(View("IssueChargesError", result.Errors)); } } } }
public async Task GetInvoiceRuns_ForDevolvedAuthority_ReturnsInvoiceRunsViewWithModelNotAllowingInvoiceDownload() { // Arrange IReadOnlyList <InvoiceRunInfo> results = A.Dummy <IReadOnlyList <InvoiceRunInfo> >(); IWeeeClient weeeClient = A.Fake <IWeeeClient>(); A.CallTo(() => weeeClient.SendAsync(A <FetchInvoiceRuns> ._)).Returns(results); ChargeController controller = new ChargeController( A.Dummy <IAppConfiguration>(), A.Dummy <BreadcrumbService>(), () => weeeClient); // Act ActionResult result = await controller.InvoiceRuns(CompetentAuthority.Scotland); // Assert ViewResult viewResult = result as ViewResult; Assert.NotNull(viewResult); Assert.True(viewResult.ViewName == string.Empty || viewResult.ViewName == "InvoiceRuns"); IReadOnlyList <InvoiceRunInfo> viewModel = viewResult.Model as IReadOnlyList <InvoiceRunInfo>; Assert.NotNull(viewModel); Assert.Equal(results, viewModel); Assert.Equal(false, viewResult.ViewBag.AllowDownloadOfInvoiceFiles); }
public async void GetConfirmRemoval_ReturnsHttpForbiddenResult_WhenCanRemoveProducerIsFalse() { // Arrange IWeeeClient weeeClient = A.Fake <IWeeeClient>(); ProducersController controller = new ProducersController( A.Dummy <BreadcrumbService>(), A.Dummy <ISearcher <ProducerSearchResult> >(), () => weeeClient, A.Dummy <IWeeeCache>(), configurationService); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetProducerDetailsByRegisteredProducerId> ._)) .Returns( new ProducerDetailsScheme { CanRemoveProducer = false }); // Act var result = await controller.ConfirmRemoval(A.Dummy <Guid>()); // Assert Assert.IsType <HttpForbiddenResult>(result); }
public async void HttpGet_DownloadProducerEeeHistoryCsv_ShouldReturnFileContentType() { // Arrange BreadcrumbService breadcrumb = A.Dummy <BreadcrumbService>(); ISearcher <ProducerSearchResult> producerSearcher = A.Dummy <ISearcher <ProducerSearchResult> >(); IWeeeClient weeeClient = A.Fake <IWeeeClient>(); CSVFileData csvData = A.Dummy <CSVFileData>(); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetProducerEeeDataHistoryCsv> ._)) .Returns(new CSVFileData { FileName = "test.csv", FileContent = "123,abc" }); Func <IWeeeClient> weeeClientFunc = A.Fake <Func <IWeeeClient> >(); A.CallTo(() => weeeClientFunc()) .Returns(weeeClient); ProducersController controller = new ProducersController(breadcrumb, producerSearcher, weeeClientFunc, cache, configurationService); //Act var result = await controller.DownloadProducerEeeDataHistoryCsv("WEE/AA1111AA"); //Assert Assert.IsType <FileContentResult>(result); }
private async Task <OrganisationSearchDataResult> FetchOrganisations(string companyName, int?page) { using (IWeeeClient client = apiClient()) { return(await client.SendAsync(User.GetAccessToken(), new FindMatchingOrganisations(companyName))); } }
public async void GetConfirmRemoval_ReturnsConfirmRemovalView_WhenCanRemoveProducerIsTrue() { // Arrange IWeeeClient weeeClient = A.Fake <IWeeeClient>(); ProducersController controller = new ProducersController( A.Dummy <BreadcrumbService>(), A.Dummy <ISearcher <ProducerSearchResult> >(), () => weeeClient, A.Dummy <IWeeeCache>(), configurationService); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetProducerDetailsByRegisteredProducerId> ._)) .Returns( new ProducerDetailsScheme { CanRemoveProducer = true }); // Act ActionResult result = await controller.ConfirmRemoval(A.Dummy <Guid>()); // Assert ViewResult viewResult = result as ViewResult; Assert.NotNull(viewResult); Assert.True(string.IsNullOrEmpty(viewResult.ViewName) || viewResult.ViewName.ToLowerInvariant() == "confirmremoval"); }
public async Task GetDownloadChargeBreakdown_CallsApiAndReturnsFileResult() { // Arrange Guid invoiceRunId = Guid.NewGuid(); var csvFileData = new CSVFileData { FileName = "Test file.csv", FileContent = "CSV content" }; IWeeeClient weeeClient = A.Fake <IWeeeClient>(); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <FetchInvoiceRunCsv> ._)) .WhenArgumentsMatch(a => a.Get <FetchInvoiceRunCsv>("request").InvoiceRunId == invoiceRunId) .Returns(csvFileData); ChargeController controller = new ChargeController( A.Dummy <IAppConfiguration>(), A.Dummy <BreadcrumbService>(), () => weeeClient); // Act ActionResult result = await controller.DownloadChargeBreakdown(invoiceRunId); // Assert FileResult fileResult = result as FileResult; Assert.NotNull(fileResult); Assert.Equal("Test file.csv", fileResult.FileDownloadName); Assert.Equal("text/csv", fileResult.ContentType); }
private async Task <bool> CheckOrganisationExists(Guid organisationID) { using (IWeeeClient client = apiClient()) { return(await client.SendAsync(User.GetAccessToken(), new VerifyOrganisationExists(organisationID))); } }
public ProducersControllerTests() { breadcumbService = A.Fake<BreadcrumbService>(); producerSearcher = A.Fake<ISearcher<ProducerSearchResult>>(); weeeClient = A.Fake<IWeeeClient>(); cache = A.Fake<IWeeeCache>(); }
public async Task PostManagePendingCharges_NonAjaxWithNoError_CallsApiAndRedirectsToChargesSuccessfullyIssuedActionWithAuthorityAndInvoiceRunId() { Guid invoiceRunId = new Guid("FB95F6E7-8809-488A-B23B-5B3F5A9B3D5F"); IWeeeClient weeeClient = A.Fake <IWeeeClient>(); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <IssuePendingCharges> ._)) .Returns(new IssuePendingChargesResult { Errors = new List <string>(), InvoiceRunId = invoiceRunId }); // Arrange ChargeController controller = new ChargeController( A.Dummy <IAppConfiguration>(), A.Dummy <BreadcrumbService>(), () => weeeClient); HttpContextBase httpContext = A.Fake <HttpContextBase>(); HttpRequestBase httpRequest = A.Fake <HttpRequestBase>(); A.CallTo(() => httpContext.Request).Returns(httpRequest); controller.ControllerContext = new ControllerContext(httpContext, new RouteData(), controller); // Act ActionResult result = await controller.ManagePendingCharges(CompetentAuthority.NorthernIreland, A.Dummy <FormCollection>()); // Assert RedirectToRouteResult redirectResult = result as RedirectToRouteResult; Assert.NotNull(redirectResult); Assert.Equal("ChargesSuccessfullyIssued", redirectResult.RouteValues["action"]); Assert.Equal(CompetentAuthority.NorthernIreland, redirectResult.RouteValues["authority"]); Assert.Equal(invoiceRunId, redirectResult.RouteValues["id"]); }
public async Task GetDownloadIssuedChargesCsv_Always_CallsApiAndReturnsFileResultWithCorrectFileName() { // Arrange CompetentAuthority authority = A.Dummy <CompetentAuthority>(); int complianceYear = A.Dummy <int>(); Guid schemeId = A.Dummy <Guid>(); IWeeeClient weeeClient = A.Fake <IWeeeClient>(); FileInfo fileInfo = new FileInfo("filename", new byte[] { 1, 2, 3 }); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <FetchIssuedChargesCsv> ._)) .WhenArgumentsMatch(a => a.Get <FetchIssuedChargesCsv>("request").Authority == authority && a.Get <FetchIssuedChargesCsv>("request").ComplianceYear == complianceYear && a.Get <FetchIssuedChargesCsv>("request").SchemeId == schemeId) .Returns(fileInfo); ChargeController controller = new ChargeController( A.Dummy <IAppConfiguration>(), A.Dummy <BreadcrumbService>(), () => weeeClient); // Act ActionResult result = await controller.DownloadIssuedChargesCsv(authority, complianceYear, schemeId); // Assert FileResult fileResult = result as FileResult; Assert.NotNull(fileResult); Assert.Equal("filename", fileResult.FileDownloadName); }
/// <summary> /// This test ensures that the OnActionExecuting filter doesn't interupt the action when the configuration /// has data returns enabled, the specified "pcsId" parameter is for a non-approved scheme and the user /// is requesting the "AuthorisationRequired" action. This prevents an infinite loop from occuring. /// </summary> public void OnActionExecuting_ConfigEnabledAndSpecifiedSchemeIsNotApprovedAndActionIsAuthorisationRequired_DoesNothing() { // Arrange IAppConfiguration configuration = A.Fake <IAppConfiguration>(); A.CallTo(() => configuration.EnableDataReturns).Returns(true); ConfigurationService configurationService = A.Fake <ConfigurationService>(); A.CallTo(() => configurationService.CurrentConfiguration).Returns(configuration); IWeeeClient weeeClient = A.Fake <IWeeeClient>(); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <VerifyOrganisationExists> ._)) .WhenArgumentsMatch(a => a.Get <VerifyOrganisationExists>("request").OrganisationId == new Guid("51254A73-D885-4F9A-BC47-2787CB1416B9")) .Returns(true); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetSchemeStatus> ._)) .WhenArgumentsMatch(a => a.Get <GetSchemeStatus>("request").PcsId == new Guid("51254A73-D885-4F9A-BC47-2787CB1416B9")) .Returns(SchemeStatus.Pending); DataReturnsController controller = new DataReturnsController( () => weeeClient, A.Dummy <IWeeeCache>(), A.Dummy <BreadcrumbService>(), A.Dummy <CsvWriterFactory>(), A.Dummy <IMapper>(), configurationService); // Act ActionDescriptor actionDescriptor = A.Fake <ActionDescriptor>(); A.CallTo(() => actionDescriptor.ActionName == "AuthorisationRequired"); ActionExecutingContext actionExecutingContext = new ActionExecutingContext(); actionExecutingContext.ActionParameters = new Dictionary <string, object>(); actionExecutingContext.ActionParameters["pcsId"] = new Guid("51254A73-D885-4F9A-BC47-2787CB1416B9"); actionExecutingContext.ActionDescriptor = actionDescriptor; MethodInfo onActionExecutingMethod = typeof(DataReturnsController).GetMethod( "OnActionExecuting", BindingFlags.NonPublic | BindingFlags.Instance); Action testCode = () => { object[] args = new object[] { actionExecutingContext }; try { onActionExecutingMethod.Invoke(controller, args); } catch (TargetInvocationException ex) { throw ex.InnerException; } }; // Assert Assert.Null(actionExecutingContext.Result); }
public async Task GetDownloadEeeWeeeData_Always_CallsApiAndReturnsFileContents() { // Arrange Guid organisationId = new Guid("ADED8BDE-CF03-4696-B972-DDAB9306A6DD"); FileInfo fileInfo = new FileInfo("Test file.csv", A.Dummy <byte[]>()); IWeeeClient client = A.Fake <IWeeeClient>(); A.CallTo(() => client.SendAsync(A <string> ._, A <FetchSummaryCsv> ._)) .WhenArgumentsMatch(a => a.Get <FetchSummaryCsv>("request").OrganisationId == organisationId && a.Get <FetchSummaryCsv>("request").ComplianceYear == 2017) .Returns(fileInfo); DataReturnsController controller = new DataReturnsController( () => client, A.Dummy <IWeeeCache>(), A.Dummy <BreadcrumbService>(), A.Dummy <CsvWriterFactory>(), A.Dummy <IMapper>(), A.Dummy <ConfigurationService>()); // Act ActionResult result = await controller.DownloadEeeWeeeData(organisationId, 2017); // Assert FileResult fileResult = result as FileResult; Assert.NotNull(fileResult); Assert.Equal("Test file.csv", fileResult.FileDownloadName); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { // Ensure that Data Returns are enabled. if (!configService.CurrentConfiguration.EnableDataReturns) { throw new InvalidOperationException("Data returns are not enabled."); } // Ensure a organisation ID has been provided and that the organisation exists. object organisationIdActionParameter; if (!filterContext.ActionParameters.TryGetValue("pcsId", out organisationIdActionParameter)) { throw new ArgumentException("No organisation ID was specified."); } if (!(organisationIdActionParameter is Guid)) { throw new ArgumentException("The specified organisation ID is not valid."); } Guid organisationId = (Guid)organisationIdActionParameter; bool organisationExists; using (IWeeeClient client = apiClient()) { Task <bool> task = Task.Run(() => client.SendAsync(User.GetAccessToken(), new VerifyOrganisationExists(organisationId))); task.Wait(); organisationExists = task.Result; } if (!organisationExists) { throw new ArgumentException(string.Format("'{0}' is not a valid organisation Id.", organisationId)); } /* Check whether the scheme representing the organisation has a status of "Approved". * If not, redirect the user to the "AuthorisationRequired" action (unless they are * already executing that action). */ if (filterContext.ActionDescriptor.ActionName != "AuthorisationRequired") { SchemeStatus status; using (IWeeeClient client = apiClient()) { Task <SchemeStatus> schemeStatusTask = Task.Run(() => client.SendAsync(User.GetAccessToken(), new GetSchemeStatus(organisationId))); schemeStatusTask.Wait(); status = schemeStatusTask.Result; } if (status != SchemeStatus.Approved) { filterContext.Result = RedirectToAction("AuthorisationRequired", new { organisationId }); return; } } base.OnActionExecuting(filterContext); }
public AatfTaskListControllerTests() { fixture = new Fixture(); weeeClient = A.Fake <IWeeeClient>(); breadcrumb = A.Fake <BreadcrumbService>(); mapper = A.Fake <IMapper>(); controller = new AatfTaskListController(() => weeeClient, breadcrumb, A.Fake <IWeeeCache>(), mapper); }
public CheckYourReturnControllerTests() { weeeClient = A.Fake <IWeeeClient>(); breadcrumb = A.Fake <BreadcrumbService>(); mapper = A.Fake <IMapper>(); controller = new CheckYourReturnController(() => weeeClient, A.Fake <IWeeeCache>(), breadcrumb, mapper); }
public AccountControllerTest() { apiClient = A.Fake <IWeeeClient>(); authenticationManager = A.Fake <IAuthenticationManager>(); oauthClient = A.Fake <IOAuthClient>(); userInfoClient = A.Fake <IUserInfoClient>(); externalRouteService = A.Fake <IExternalRouteService>(); }
public UserControllerTests() { fixture = new Fixture(); weeeClient = A.Fake <IWeeeClient>(); apiClient = () => weeeClient; mapper = A.Fake <IMapper>(); controller = new UserController(apiClient, A.Fake <BreadcrumbService>(), mapper); }
public AccountControllerTest() { apiClient = A.Fake<IWeeeClient>(); authenticationManager = A.Fake<IAuthenticationManager>(); oauthClient = A.Fake<IOAuthClient>(); userInfoClient = A.Fake<IUserInfoClient>(); externalRouteService = A.Fake<IExternalRouteService>(); }
public ReusedOffSiteControllerTests() { weeeClient = A.Fake <IWeeeClient>(); breadcrumb = A.Fake <BreadcrumbService>(); cache = A.Fake <IWeeeCache>(); controller = new ReusedOffSiteController(() => weeeClient, breadcrumb, cache); }
public AccountControllerTests() { apiClient = A.Fake <IWeeeClient>(); oauthClientCredentialClient = A.Fake <IOAuthClientCredentialClient>(); unauthenticatedUserClient = A.Fake <IUnauthenticatedUser>(); weeeAuthorization = A.Fake <IWeeeAuthorization>(); externalRouteService = A.Fake <IExternalRouteService>(); }
private async Task <ProducerDetailsScheme> FetchProducerDetailsScheme(Guid registeredProducerId) { using (IWeeeClient client = apiClient()) { GetProducerDetailsByRegisteredProducerId request = new GetProducerDetailsByRegisteredProducerId(registeredProducerId); return(await client.SendAsync(User.GetAccessToken(), request)); } }
public ObligatedValuesCopyPasteControllerTests() { breadcrumb = A.Fake <BreadcrumbService>(); cache = A.Fake <IWeeeCache>(); weeeClient = weeeClient = A.Fake <IWeeeClient>(); controller = new ObligatedValuesCopyPasteController(() => weeeClient, breadcrumb, cache); }
public ReusedRemoveSiteControllerTests() { this.apiClient = A.Fake <IWeeeClient>(); this.breadcrumb = A.Fake <BreadcrumbService>(); this.cache = A.Fake <IWeeeCache>(); this.mapper = A.Fake <IMap <ReturnAndAatfToReusedRemoveSiteViewModelMapTransfer, ReusedRemoveSiteViewModel> >(); controller = new ReusedRemoveSiteController(() => apiClient, breadcrumb, cache, mapper); }
public ReusedOffSiteCreateSiteControllerTests() { weeeClient = A.Fake <IWeeeClient>(); breadcrumb = A.Fake <BreadcrumbService>(); cache = A.Fake <IWeeeCache>(); requestCreator = A.Fake <IObligatedReusedSiteRequestCreator>(); mapper = A.Fake <IMap <SiteAddressDataToReusedOffSiteCreateSiteViewModelMapTransfer, ReusedOffSiteCreateSiteViewModel> >(); controller = new ReusedOffSiteCreateSiteController(() => weeeClient, breadcrumb, cache, requestCreator, mapper); }
public SentOnSiteSummaryListControllerTests() { this.apiClient = A.Fake <IWeeeClient>(); this.breadcrumb = A.Fake <BreadcrumbService>(); this.cache = A.Fake <IWeeeCache>(); this.mapper = A.Fake <IMap <ReturnAndAatfToSentOnSummaryListViewModelMapTransfer, SentOnSiteSummaryListViewModel> >(); controller = new SentOnSiteSummaryListController(() => apiClient, breadcrumb, cache, mapper); }
private async Task <IEnumerable <SchemeData> > GetSchemesWithInvoices(CompetentAuthority authority) { FetchSchemesWithInvoices request = new FetchSchemesWithInvoices(authority); using (IWeeeClient client = weeeClient()) { return(await client.SendAsync(User.GetAccessToken(), request)); } }
public ReceivedPcsListControllerTests() { weeeClient = A.Fake <IWeeeClient>(); breadcrumb = A.Fake <BreadcrumbService>(); mapper = A.Fake <IMap <ReturnAndSchemeDataToReceivedPcsViewModelMapTransfer, ReceivedPcsListViewModel> >(); cache = A.Fake <IWeeeCache>(); controller = new ReceivedPcsListController(() => weeeClient, cache, breadcrumb, mapper); }
public SubmissionsControllerTests() { weeeClient = A.Fake<IWeeeClient>(); }
private static DataReturnsController GetDummyDataReturnsController(IWeeeClient weeeClient) { DataReturnsController controller = new DataReturnsController( () => weeeClient, A.Dummy<IWeeeCache>(), A.Dummy<BreadcrumbService>(), A.Dummy<CsvWriterFactory>(), A.Dummy<IMapper>(), A.Dummy<ConfigurationService>()); new HttpContextMocker().AttachToController(controller); return controller; }
public FakeDataReturnsController( IWeeeClient apiClient, IWeeeCache cache, BreadcrumbService breadcrumb, CsvWriterFactory csvWriterFactory, IMapper mapper, ConfigurationService configurationService) : base(() => apiClient, cache, breadcrumb, csvWriterFactory, mapper, configurationService) { ApiClient = apiClient; }
private async Task<OrganisationData> GetOrganisation(Guid? organisationId, IWeeeClient client) { var organisationExistsAndIncomplete = await client.SendAsync(User.GetAccessToken(), new VerifyOrganisationExistsAndIncomplete(organisationId.Value)); if (!organisationExistsAndIncomplete) { throw new ArgumentException("No organisation found for supplied organisation Id with Incomplete status", "organisationId"); } var organisation = await client.SendAsync(User.GetAccessToken(), new GetOrganisationInfo(organisationId.Value)); return organisation; }
private async Task AddAddressToOrganisation(AddressViewModel model, AddressType type, IWeeeClient client) { var request = model.ToAddRequest(type); await client.SendAsync(User.GetAccessToken(), request); }
private async Task<AddressPrepopulateViewModel> GetAddressPrepopulateViewModel(Guid organisationId, IWeeeClient client) { var organisation = await client.SendAsync(User.GetAccessToken(), new GetOrganisationInfo(organisationId)); var model = new AddressPrepopulateViewModel { OrganisationId = organisationId, OrganisationType = organisation.OrganisationType, }; return model; }
private async Task<AddressViewModel> GetAddressViewModel(Guid organisationId, IWeeeClient client, bool regionsOfUKOnly, AddressType addressType) { // Check the organisation Id is valid var organisation = await client.SendAsync(User.GetAccessToken(), new GetOrganisationInfo(organisationId)); var model = new AddressViewModel { OrganisationId = organisationId, OrganisationType = organisation.OrganisationType, }; if (addressType == AddressType.OrganisationAddress) { if (organisation.HasOrganisationAddress) { model.Address = organisation.OrganisationAddress; } } else if (addressType == AddressType.RegisteredOrPPBAddress) { if (organisation.HasBusinessAddress) { model.Address = organisation.BusinessAddress; } } else if (addressType == AddressType.ServiceOfNotice) { if (organisation.HasNotificationAddress) { model.Address = organisation.NotificationAddress; } } model.Address.Countries = await GetCountries(regionsOfUKOnly); return model; }
public DataReturnsControllerTests() { weeeClient = A.Fake<IWeeeClient>(); mapper = A.Fake<IMapper>(); configService = A.Fake<ConfigurationService>(); }
public UserControllerTests() { weeeClient = A.Fake<IWeeeClient>(); apiClient = () => weeeClient; }
public TestEmailControllerTests() { weeeClient = A.Fake<IWeeeClient>(); }
public MemberRegistrationControllerTests() { weeeClient = A.Fake<IWeeeClient>(); mapper = A.Fake<IMapper>(); }
public FakeMemberRegistrationController( IWeeeClient apiClient, IWeeeCache cache, BreadcrumbService breadcrumb, CsvWriterFactory csvWriterFactory, IMapper mapper) : base(() => apiClient, cache, breadcrumb, csvWriterFactory, mapper) { ApiClient = apiClient; }