コード例 #1
0
        public async Task HandleAsync_GivenMessageContainingUpdatedAmounts_AmountsAreUpdatedCorrectly()
        {
            var updatedValues = new List <ObligatedValue>()
            {
                new ObligatedValue(Guid.NewGuid(), A.Dummy <int>(), 1, 2),
                new ObligatedValue(Guid.NewGuid(), A.Dummy <int>(), 3, 4)
            };

            var message = new EditObligatedSentOn()
            {
                CategoryValues = updatedValues
            };

            var returnAmounts = new List <WeeeSentOnAmount>()
            {
                new WeeeSentOnAmount(A.Dummy <WeeeSentOn>(), A.Dummy <int>(), A.Dummy <decimal?>(), A.Dummy <decimal?>()),
                new WeeeSentOnAmount(A.Dummy <WeeeSentOn>(), A.Dummy <int>(), A.Dummy <decimal?>(), A.Dummy <decimal?>())
            };

            A.CallTo(() => genericDataAccess.GetById <WeeeSentOnAmount>(updatedValues.ElementAt(0).Id)).Returns(returnAmounts.ElementAt(0));
            A.CallTo(() => genericDataAccess.GetById <WeeeSentOnAmount>(updatedValues.ElementAt(1).Id)).Returns(returnAmounts.ElementAt(1));

            await handler.HandleAsync(message);

            A.CallTo(() => obligatedSentOnDataAccess.UpdateAmounts(returnAmounts.ElementAt(0), 1, 2)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => obligatedSentOnDataAccess.UpdateAmounts(returnAmounts.ElementAt(1), 3, 4)).MustHaveHappened(Repeated.Exactly.Once);
        }
コード例 #2
0
        public async Task HandleAsync_NoExternalAccess_ThrowsSecurityException()
        {
            var authorization = new AuthorizationBuilder().DenyExternalAreaAccess().Build();

            var handlerLocal = new EditObligatedSentOnHandler(authorization, obligatedSentOnDataAccess, genericDataAccess);

            Func <Task> action = async() => await handlerLocal.HandleAsync(A.Dummy <EditObligatedSentOn>());

            await action.Should().ThrowAsync <SecurityException>();
        }