Beispiel #1
0
        public async Task GetComplianceYearsHandler_NotOrganisationUser_ThrowsSecurityException()
        {
            // Arrange
            Guid pcsId = new Guid("A7905BCD-8EE7-48E5-9E71-2B571F7BBC81");

            IWeeeAuthorization authorization = new AuthorizationBuilder().DenyInternalOrOrganisationAccess().Build();
            WeeeContext        context       = A.Fake <WeeeContext>();

            GetComplianceYearsHandler handler = new GetComplianceYearsHandler(authorization, context);

            GetComplianceYears request = new GetComplianceYears(pcsId);

            // Act
            Func <Task> action = async() => await handler.HandleAsync(request);

            // Asert
            await Assert.ThrowsAsync <SecurityException>(action);
        }
        public async Task GetComplianceYearsHandler_NotOrganisationUser_ThrowsSecurityException()
        {
            // Arrange
            Guid pcsId = new Guid("A7905BCD-8EE7-48E5-9E71-2B571F7BBC81");

            IWeeeAuthorization authorization = new AuthorizationBuilder().DenyInternalOrOrganisationAccess().Build();
            WeeeContext context = A.Fake<WeeeContext>();

            GetComplianceYearsHandler handler = new GetComplianceYearsHandler(authorization, context);

            GetComplianceYears request = new GetComplianceYears(pcsId);

            // Act
            Func<Task> action = async () => await handler.HandleAsync(request); 

            // Asert
            await Assert.ThrowsAsync<SecurityException>(action);
        }
        public async Task GetComplianceYearsHandler_OrganisationDoesNotExist_ThrowsArgumentException()
        {
            // Arrange
            Guid pcsId = new Guid("A7905BCD-8EE7-48E5-9E71-2B571F7BBC81");

            IWeeeAuthorization authorization = AuthorizationBuilder.CreateUserWithAllRights();
            
            WeeeContext context = A.Fake<WeeeContext>();
            var organisations = dbContextHelper.GetAsyncEnabledDbSet<Organisation>(new List<Organisation>());
            A.CallTo(() => organisations.FindAsync(pcsId)).Returns((Organisation)null);
            A.CallTo(() => context.Organisations).Returns(organisations);

            GetComplianceYearsHandler handler = new GetComplianceYearsHandler(authorization, context);

            GetComplianceYears request = new GetComplianceYears(pcsId);

            // Act
            Func<Task> action = async () => await handler.HandleAsync(request);

            // Asert
            await Assert.ThrowsAsync<ArgumentException>(action);
        }
Beispiel #4
0
        public async Task GetComplianceYearsHandler_OrganisationDoesNotExist_ThrowsArgumentException()
        {
            // Arrange
            Guid pcsId = new Guid("A7905BCD-8EE7-48E5-9E71-2B571F7BBC81");

            IWeeeAuthorization authorization = AuthorizationBuilder.CreateUserWithAllRights();

            WeeeContext context       = A.Fake <WeeeContext>();
            var         organisations = dbContextHelper.GetAsyncEnabledDbSet <Organisation>(new List <Organisation>());

            A.CallTo(() => organisations.FindAsync(pcsId)).Returns((Organisation)null);
            A.CallTo(() => context.Organisations).Returns(organisations);

            GetComplianceYearsHandler handler = new GetComplianceYearsHandler(authorization, context);

            GetComplianceYears request = new GetComplianceYears(pcsId);

            // Act
            Func <Task> action = async() => await handler.HandleAsync(request);

            // Asert
            await Assert.ThrowsAsync <ArgumentException>(action);
        }