public async Task HandleAsync_WithValidInput_SubmitIsCalledCorrectly() { var siteRequest = AddAatfSiteRequest(); var weeReused = new WeeeReused(siteRequest.AatfId, siteRequest.ReturnId); var country = new Country(A.Dummy <Guid>(), A.Dummy <string>()); A.CallTo(() => organisationDetailsDataAccess.FetchCountryAsync(siteRequest.AddressData.CountryId)).Returns(country); A.CallTo(() => genericDataAccess.GetManyByExpression( A <WeeeReusedByAatfIdAndReturnIdSpecification> .That.Matches(w => w.AatfId == siteRequest.AatfId && w.ReturnId == siteRequest.ReturnId))).Returns(new List <WeeeReused>() { weeReused }); await handler.HandleAsync(siteRequest); A.CallTo(() => addAatfSiteDataAccess.Submit(A <WeeeReusedSite> .That.Matches(w => w.Address.Address1.Equals(siteRequest.AddressData.Address1) && w.Address.Address2.Equals(siteRequest.AddressData.Address2) && w.Address.CountyOrRegion.Equals(siteRequest.AddressData.CountyOrRegion) && w.Address.TownOrCity.Equals(siteRequest.AddressData.TownOrCity) && w.Address.Postcode.Equals(siteRequest.AddressData.Postcode) && w.Address.Country.Equals(country) && w.WeeeReused.Equals(weeReused)))).MustHaveHappened(Repeated.Exactly.Once); }
public void WeeeReused_AatfNotDefined_ThrowsArgumentNullException() { Action constructor = () => { var @return = new WeeeReused(null, A.Dummy <Return>()); }; constructor.Should().Throw <ArgumentNullException>(); }
public void WeeeReused_GivenValidParameters_WeeeReceivedPropertiesShouldBeSet() { var aatf = A.Fake <Aatf>(); var @return = A.Fake <Return>(); var weeeReceived = new WeeeReused(aatf, @return); weeeReceived.Aatf.Should().Be(aatf); weeeReceived.Return.Should().Be(@return); }
public void Submit_GivenObligatedWeeeValues_ValuesShouldBeAddedToContext() { var weeeReused = new WeeeReused(aatfId, Guid.NewGuid()); decimal houseHoldTonnage = 1.000m; decimal nonHouseHoldTonnage = 2.000m; var obligatedReceivedWeee = new List <WeeeReusedAmount> { new WeeeReusedAmount(weeeReused, 1, houseHoldTonnage, nonHouseHoldTonnage), new WeeeReusedAmount(weeeReused, 2, houseHoldTonnage, nonHouseHoldTonnage) }; var obligatedReceivedWeeeDbSet = dbContextHelper.GetAsyncEnabledDbSet(new List <WeeeReusedAmount>()); A.CallTo(() => context.WeeeReusedAmount).Returns(obligatedReceivedWeeeDbSet); dataAccess.Submit(obligatedReceivedWeee); context.WeeeReusedAmount.Should().AllBeEquivalentTo(obligatedReceivedWeee); }
public async Task <bool> HandleAsync(AddObligatedReused message) { authorization.EnsureCanAccessExternalArea(); var aatfWeeeReused = new WeeeReused( message.AatfId, message.ReturnId); var aatfWeeeReusedAmount = new List <WeeeReusedAmount>(); foreach (var categoryValue in message.CategoryValues) { aatfWeeeReusedAmount.Add(new WeeeReusedAmount(aatfWeeeReused, categoryValue.CategoryId, categoryValue.HouseholdTonnage, categoryValue.NonHouseholdTonnage)); } await obligatedReusedDataAccess.Submit(aatfWeeeReusedAmount); return(true); }
public void Submit_GivenReusedSiteData_ValuesShouldBeAddedToContext() { var aatfAddress = new AatfAddress( "Name", "Address", A.Dummy <string>(), "TownOrCity", A.Dummy <string>(), A.Dummy <string>(), A.Dummy <Country>()); var weeeReused = new WeeeReused(aatfId, A.Dummy <Guid>()); var weeeReusedSite = new WeeeReusedSite(weeeReused, aatfAddress); var weeeReusedSiteDbSet = dbContextHelper.GetAsyncEnabledDbSet(new List <WeeeReusedSite>()); A.CallTo(() => context.WeeeReusedSite).Returns(weeeReusedSiteDbSet); dataAccess.Submit(weeeReusedSite); context.WeeeReusedSite.Should().AllBeEquivalentTo(weeeReusedSite); }
public async Task HandleAsync_WithValidInput_SubmittedIsCalledCorrectly() { var aatf = A.Fake <Aatf>(); var aatfReturn = ReturnHelper.GetReturn(); var weeeReused = new WeeeReused( aatf.Id, aatfReturn.Id); var weeeReusedAmount = new List <WeeeReusedAmount>(); var categoryValues = new List <ObligatedValue>(); foreach (var category in Enum.GetValues(typeof(WeeeCategory)).Cast <WeeeCategory>()) { categoryValues.Add(new ObligatedValue(Guid.NewGuid(), (int)category, (int)category, (int)category)); } var obligatedWeeeRequest = new AddObligatedReused { AatfId = aatf.Id, ReturnId = aatfReturn.Id, OrganisationId = aatfReturn.Organisation.Id, CategoryValues = categoryValues }; foreach (var categoryValue in obligatedWeeeRequest.CategoryValues) { weeeReusedAmount.Add(new WeeeReusedAmount(weeeReused, categoryValue.CategoryId, categoryValue.HouseholdTonnage, categoryValue.NonHouseholdTonnage)); } var requestHandler = new AddObligatedReusedHandler(authorization, addObligatedReusedDataAccess); await requestHandler.HandleAsync(obligatedWeeeRequest); A.CallTo(() => addObligatedReusedDataAccess.Submit(A <List <WeeeReusedAmount> > .That.IsSameAs(weeeReusedAmount))); }
public WeeeReused ReturnWeeeReused(Aatf aatf, Return @return) { var weeeReused = new WeeeReused(aatf, @return); return(weeeReused); }