public async Task <ActionResult> IssuedCharges(CompetentAuthority authority, IssuedChargesViewModel viewModel) { ViewBag.Authority = authority; ViewBag.TriggerDownload = ModelState.IsValid; viewModel.ComplianceYears = await GetComplianceYearsWithInvoices(authority); viewModel.Schemes = await GetSchemesWithInvoices(authority); return(View(viewModel)); }
public async Task GetIssuedCharges_Always_CallsApiAndPopulatesViewModel() { // Arrange CompetentAuthority authority = A.Dummy <CompetentAuthority>(); IWeeeClient weeeClient = A.Fake <IWeeeClient>(); List <int> complianceYears = A.Dummy <List <int> >(); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <FetchComplianceYearsWithInvoices> ._)) .WhenArgumentsMatch(a => a.Get <FetchComplianceYearsWithInvoices>("request").Authority == authority) .Returns(complianceYears); List <SchemeData> schemes = A.Dummy <List <SchemeData> >(); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <FetchSchemesWithInvoices> ._)) .WhenArgumentsMatch(a => a.Get <FetchSchemesWithInvoices>("request").Authority == authority) .Returns(schemes); ChargeController controller = new ChargeController( A.Dummy <IAppConfiguration>(), A.Dummy <BreadcrumbService>(), () => weeeClient); // Act ActionResult result = await controller.IssuedCharges(authority); // Assert ViewResult viewResult = result as ViewResult; Assert.NotNull(viewResult); IssuedChargesViewModel viewModel = viewResult.Model as IssuedChargesViewModel; Assert.NotNull(viewModel); Assert.Equal(complianceYears, viewModel.ComplianceYears); Assert.Equal(schemes, viewModel.Schemes); }
public async Task<ActionResult> IssuedCharges(CompetentAuthority authority, IssuedChargesViewModel viewModel) { ViewBag.Authority = authority; ViewBag.TriggerDownload = ModelState.IsValid; viewModel.ComplianceYears = await GetComplianceYearsWithInvoices(authority); viewModel.SchemeNames = await GetSchemesWithInvoices(authority); return View(viewModel); }