コード例 #1
0
        public async Task OrganisationByIdHandler_NotInternalUser_ThrowsSecurityException()
        {
            var authorization = AuthorizationBuilder.CreateFromUserType(AuthorizationBuilder.UserType.External);

            var handler = new OrganisationInternalByIdHandler(authorization, context, map);
            var message = new GetInternalOrganisation(Guid.NewGuid());

            await Assert.ThrowsAsync <SecurityException>(async() => await handler.HandleAsync(message));
        }
コード例 #2
0
        public async Task OrganisationByIdHandler_NoSuchOrganisation_ThrowsArgumentException()
        {
            var message = new GetInternalOrganisation(organisationId);

            A.CallTo(() => context.Organisations).Returns(dbHelper.GetAsyncEnabledDbSet(new List <Organisation>()));

            var exception = await Assert.ThrowsAsync <ArgumentException>(async() => await handler.HandleAsync(message));

            Assert.True(exception.Message.Contains(organisationId.ToString()));
            Assert.True(exception.Message.ToUpperInvariant().Contains("COULD NOT FIND"));
            Assert.True(exception.Message.ToUpperInvariant().Contains("ORGANISATION"));
        }
コード例 #3
0
        public async Task OrganisationByIdHandler_GivenMappedOrganisation_MappedOrganisationShouldBeReturned()
        {
            var message = new GetInternalOrganisation(organisationId);

            var expectedReturnValue = new OrganisationData();

            A.CallTo(() => map.Map(A <Organisation> ._)).Returns(expectedReturnValue);

            var result = await handler.HandleAsync(message);

            result.Should().Be(expectedReturnValue);
        }
コード例 #4
0
        public async Task OrganisationByIdHandler_ReturnsFalseForCanEditOrganisation_WhenCurrentUserIsNotInternalAdmin()
        {
            var weeeAuthorization = new AuthorizationBuilder()
                                    .AllowInternalAreaAccess()
                                    .DenyRole(Roles.InternalAdmin)
                                    .Build();

            var handler = new OrganisationInternalByIdHandler(weeeAuthorization, context, map);

            var message = new GetInternalOrganisation(organisationId);

            var result = await handler.HandleAsync(message);

            result.CanEditOrganisation.Should().BeFalse();
        }
コード例 #5
0
        public async Task OrganisationByIdHandler_HappyPath_ReturnsOrganisationFromId()
        {
            var authorization = AuthorizationBuilder.CreateUserWithAllRights();

            var expectedReturnValue = new OrganisationData();

            A.CallTo(() => map.Map(A <Organisation> ._)).Returns(expectedReturnValue);

            var message = new GetInternalOrganisation(organisationId);

            var result = await handler.HandleAsync(message);

            Assert.NotNull(expectedReturnValue);
            Assert.Same(expectedReturnValue, result);
        }