コード例 #1
0
        public async Task HandleAsync_NoExternalAccess_ThrowsSecurityException()
        {
            var authorization = new AuthorizationBuilder().DenyExternalAreaAccess().Build();

            var handler = new RemoveAatfSiteHandler(context, authorization, genericDataAccess);

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

            await action.Should().ThrowAsync <SecurityException>();
        }
コード例 #2
0
        public async Task HandleAsync_GivenGetSentOnAatfSiteRequest_DataAccessIsCalled()
        {
            var siteAddressId          = Guid.NewGuid();
            var weeeReusedSiteId       = Guid.NewGuid();
            var siteAddress            = new AatfAddress();
            var weeeReusedSite         = new WeeeReusedSite();
            var weeeReusedSiteReturned = new WeeeReusedSite();

            A.CallTo(() => genericDataAccess.GetById <AatfAddress>(siteAddressId)).Returns(siteAddress);
            A.CallTo(() => genericDataAccess.GetSingleByExpression <WeeeReusedSite>(A <WeeeReusedByAddressIdSpecification> .That.Matches(w => w.SiteId == siteAddressId))).Returns(weeeReusedSite);
            A.CallTo(() => genericDataAccess.GetById <WeeeReusedSite>(weeeReusedSite.Id)).Returns(weeeReusedSiteReturned);

            await handler.HandleAsync(new RemoveAatfSite(siteAddressId));

            A.CallTo(() => genericDataAccess.Remove(weeeReusedSiteReturned)).MustHaveHappened(Repeated.Exactly.Once)
            .Then(A.CallTo(() => genericDataAccess.Remove(siteAddress)).MustHaveHappened(Repeated.Exactly.Once))
            .Then(A.CallTo(() => context.SaveChangesAsync()).MustHaveHappened(Repeated.Exactly.Once));
        }