public async Task HandleAsync_NoAccessToScheme_ThrowsSecurityException()
        {
            Guid pcsId = new Guid("A7905BCD-8EE7-48E5-9E71-2B571F7BBC81");
           
            Requests.DataReturns.FetchDataReturnComplianceYearsForScheme request = new Requests.DataReturns.FetchDataReturnComplianceYearsForScheme(pcsId);
            A.CallTo(() => dataAccess.FetchSchemeByOrganisationIdAsync(pcsId)).Returns(A.Dummy<Domain.Scheme.Scheme>());

            A.CallTo(() => authorization.EnsureSchemeAccess(A<Guid>._))
               .Throws<SecurityException>();

            await
                Assert.ThrowsAsync<SecurityException>(
                    () => Handler().HandleAsync(request));

            A.CallTo(() => dataAccess.GetDataReturnComplianceYearsForScheme(pcsId))
                .MustNotHaveHappened();
        }
Beispiel #2
0
        public async Task HandleAsync_NoAccessToScheme_ThrowsSecurityException()
        {
            Guid pcsId = new Guid("A7905BCD-8EE7-48E5-9E71-2B571F7BBC81");

            Requests.DataReturns.FetchDataReturnComplianceYearsForScheme request = new Requests.DataReturns.FetchDataReturnComplianceYearsForScheme(pcsId);
            A.CallTo(() => dataAccess.FetchSchemeByOrganisationIdAsync(pcsId)).Returns(A.Dummy <Domain.Scheme.Scheme>());

            A.CallTo(() => authorization.EnsureSchemeAccess(A <Guid> ._))
            .Throws <SecurityException>();

            await
            Assert.ThrowsAsync <SecurityException>(
                () => Handler().HandleAsync(request));

            A.CallTo(() => dataAccess.GetDataReturnComplianceYearsForScheme(pcsId))
            .MustNotHaveHappened();
        }