Exemplo n.º 1
0
        public async Task HandleAsync_NoExternalAccess_ThrowsSecurityException()
        {
            var authorization = new AuthorizationBuilder().DenyExternalAreaAccess().Build();

            var handler = new AddObligatedSentOnHandler(authorization, addObligatedSentOnDataAccess, genericDataAccess);

            Func <Task> action = async() => await handler.HandleAsync(A.Dummy <AddObligatedSentOn>());

            await action.Should().ThrowAsync <SecurityException>();
        }
Exemplo n.º 2
0
        public async Task HandleAsync_WithValidInput_SubmittedIsCalledCorrectly()
        {
            var aatf         = A.Fake <Aatf>();
            var weeeSentOnId = Guid.NewGuid();
            var siteAddress  = A.Fake <AatfAddress>();
            var aatfReturn   = ReturnHelper.GetReturn();

            var weeeSentOn = new WeeeSentOn(
                aatf.Id,
                aatfReturn.Id,
                siteAddress.Id);

            var weeeSentOnAmount = new List <WeeeSentOnAmount>();

            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 AddObligatedSentOn
            {
                AatfId         = aatf.Id,
                ReturnId       = aatfReturn.Id,
                OrganisationId = aatfReturn.Organisation.Id,
                CategoryValues = categoryValues,
                SiteAddressId  = siteAddress.Id,
                WeeeSentOnId   = weeeSentOnId
            };

            foreach (var categoryValue in obligatedWeeeRequest.CategoryValues)
            {
                weeeSentOnAmount.Add(new WeeeSentOnAmount(weeeSentOn, categoryValue.CategoryId, categoryValue.HouseholdTonnage, categoryValue.NonHouseholdTonnage));
            }

            var requestHandler = new AddObligatedSentOnHandler(authorization, addObligatedSentOnDataAccess, genericDataAccess);

            await requestHandler.HandleAsync(obligatedWeeeRequest);

            A.CallTo(() => addObligatedSentOnDataAccess.Submit(A <List <WeeeSentOnAmount> > .That.IsSameAs(weeeSentOnAmount)));
        }