public async Task HandleAsync_NoExternalAccess_ThrowsSecurityException() { var authorization = new AuthorizationBuilder().DenyExternalAreaAccess().Build(); var handler = new AddObligatedReusedHandler(authorization, addObligatedReusedDataAccess); Func <Task> action = async() => await handler.HandleAsync(A.Dummy <AddObligatedReused>()); await action.Should().ThrowAsync <SecurityException>(); }
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))); }