public void ViewModelToRequest_GivenAddViewModel_RequestTypeShouldBeAdd() { var model = new ObligatedViewModel(calculator); var request = requestCreator.ViewModelToRequest(model); request.Should().BeOfType <AddObligatedReceived>(); }
public void Edit_GivenSavedCategoryValuesExist_EditShouldBeTrue() { for (var count = 0; count <= viewModel.CategoryValues.Count; count++) { var local = new ObligatedViewModel(calculator); local.CategoryValues.ElementAt(0).Id = Guid.NewGuid(); local.Edit.Should().BeTrue(); } }
public void ViewModelToRequest_GivenValidViewModel_RequestShouldNotBeNull() { var categoryValues = new ObligatedCategoryValues(); var viewModel = new ObligatedViewModel(categoryValues, calculator); var request = requestCreator.ViewModelToRequest(viewModel); request.Should().NotBeNull(); }
public void ViewModelToRequest_GivenEditViewModel_RequestTypeShouldBeEdit() { var model = new ObligatedViewModel(calculator); model.CategoryValues.ElementAt(0).Id = Guid.NewGuid(); var request = requestCreator.ViewModelToRequest(model); request.Should().BeOfType <EditObligatedReceived>(); }
public async void IndexPost_GivenValidViewModel_ApiSendShouldBeCalled() { var model = new ObligatedViewModel(calculator); var request = A.Fake <ObligatedBaseRequest>(); A.CallTo(() => requestCreator.ViewModelToRequest(model)).Returns(request); await controller.Index(model); A.CallTo(() => weeeClient.SendAsync(A <string> ._, request)).MustHaveHappened(Repeated.Exactly.Once); }
public async void IndexPost_GivenNewObligatedReusedValuesAreSubmitted_PageRedirectsToAatfTaskList() { var model = new ObligatedViewModel(calculator) { ReturnId = Guid.NewGuid() }; var result = await controller.Index(model) as RedirectToRouteResult; result.RouteValues["action"].Should().Be("Index"); result.RouteValues["controller"].Should().Be("ReusedOffSite"); result.RouteValues["returnId"].Should().Be(model.ReturnId); }
public void ViewModelToRequest_GivenValidViewModel_ViewModelPropertiesShouldBeMapped() { var model = new ObligatedViewModel(calculator) { OrganisationId = Guid.NewGuid(), ReturnId = Guid.NewGuid() }; var request = requestCreator.ViewModelToRequest(model) as AddObligatedReceived; request.OrganisationId.Should().Be(model.OrganisationId); request.ReturnId.Should().Be(model.ReturnId); }
public void ViewModelToRequest_GivenEditViewModel_CategoryValuesShouldBeMapped() { var model = new ObligatedViewModel(calculator) { CategoryValues = new List <ObligatedCategoryValue>() { new ObligatedCategoryValue() } }; model.CategoryValues.ElementAt(0).Id = Guid.NewGuid(); var request = requestCreator.ViewModelToRequest(model); request.CategoryValues.Should().NotBeNull(); request.CategoryValues.Count().Should().Be(1); }
public virtual async Task <ActionResult> Index(ObligatedViewModel viewModel) { if (ModelState.IsValid) { using (var client = apiClient()) { var request = requestCreator.ViewModelToRequest(viewModel); await client.SendAsync(User.GetAccessToken(), request); return(AatfRedirect.ReceivedPcsList(viewModel.ReturnId, viewModel.AatfId)); } } await SetBreadcrumb(viewModel.OrganisationId, BreadCrumbConstant.AatfReturn, viewModel.AatfId, DisplayHelper.YearQuarterPeriodFormat(TempData["currentQuarter"] as Quarter, TempData["currentQuarterWindow"] as QuarterWindow)); return(View(viewModel)); }
public async void IndexPost_GivenEditedObligatedReusedValuesAreSubmitted_PageRedirectsToSiteSummaryList() { var categoryValues = new List <ObligatedCategoryValue>() { new ObligatedCategoryValue() { Id = Guid.NewGuid() } }; var model = new ObligatedViewModel(calculator) { ReturnId = Guid.NewGuid(), CategoryValues = categoryValues }; var result = await controller.Index(model) as RedirectToRouteResult; result.RouteValues["action"].Should().Be("Index"); result.RouteValues["controller"].Should().Be("ReusedOffSiteSummaryList"); result.RouteValues["returnId"].Should().Be(model.ReturnId); }
public void ViewModelToRequest_GivenValidViewModelWithEmptyValues_CategoryValuesRequestPropertiesShouldBeMapped(string value) { var categoryValues = new ObligatedCategoryValues(); var viewModel = new ObligatedViewModel(categoryValues, calculator); foreach (var c in categoryValues) { c.B2C = value; c.B2B = value; } var request = requestCreator.ViewModelToRequest(viewModel); for (var i = 0; i < categoryValues.Count; i++) { request.CategoryValues[i].HouseholdTonnage.Should().BeNull(); request.CategoryValues[i].NonHouseholdTonnage.Should().BeNull(); } }
public void ViewModelToRequest_GivenValidViewModelWithDecimalValues_CategoryValuesRequestPropertiesShouldBeMapped() { var categoryValues = new ObligatedCategoryValues(); var viewModel = new ObligatedViewModel(categoryValues, calculator); for (var i = 0; i < categoryValues.Count; i++) { categoryValues[i].B2C = (i * 0.001m).ToString(CultureInfo.InvariantCulture); categoryValues[i].B2B = (i * 0.001m).ToString(CultureInfo.InvariantCulture); } var request = requestCreator.ViewModelToRequest(viewModel); for (var i = 0; i < categoryValues.Count; i++) { request.CategoryValues[i].HouseholdTonnage.Should().Be(Convert.ToDecimal(viewModel.CategoryValues[i].B2C)); request.CategoryValues[i].NonHouseholdTonnage.Should().Be(Convert.ToDecimal(viewModel.CategoryValues[i].B2B)); } }
public ObligatedReusedViewModelTests() { calculator = new CategoryValueTotalCalculator(); viewModel = new ObligatedViewModel(calculator); }