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 async Task HandleAsync_NoExternalAccess_ThrowsSecurityException() { var authorization = new AuthorizationBuilder().DenyExternalAreaAccess().Build(); var handler = new AddAatfSiteHandler(weeeContext, authorization, addAatfSiteDataAccess, genericDataAccess, organisationDetailsDataAccess); Func <Task> action = async() => await handler.HandleAsync(A.Dummy <AddAatfSite>()); await action.Should().ThrowAsync <SecurityException>(); }