Esempio n. 1
0
        public async Task can_create_capability_with_an_acceptable_description(string input)
        {
            var sut = new CapabilityApplicationServiceBuilder()
                      .WithCapabilityRepository(new StubCapabilityRepository())
                      .Build();

            await sut.CreateCapability("AName", input);
        }
Esempio n. 2
0
        public async Task can_create_capability_with_an_acceptable_name(string input)
        {
            var sut = new CapabilityApplicationServiceBuilder()
                      .WithCapabilityRepository(new StubCapabilityRepository())
                      .Build();

            await sut.CreateCapability(input, string.Empty);
        }
Esempio n. 3
0
        public async Task cannot_create_capabilities_with_invalid_names(string input)
        {
            var sut = new CapabilityApplicationServiceBuilder()
                      .WithCapabilityRepository(new StubCapabilityRepository())
                      .Build();

            await Assert.ThrowsAsync <CapabilityValidationException>(() => sut.CreateCapability(input, string.Empty));
        }
Esempio n. 4
0
        public async Task throws_exception_when_adding_member_to_a_non_existing_capability()
        {
            var sut = new CapabilityApplicationServiceBuilder()
                      .WithCapabilityRepository(new StubCapabilityRepository())
                      .Build();

            var nonExistingCapabilityId = Guid.Empty;
            var dummyMemberEmail        = "*****@*****.**";

            await Assert.ThrowsAsync <CapabilityDoesNotExistException>(() => sut.JoinCapability(nonExistingCapabilityId, dummyMemberEmail));
        }
Esempio n. 5
0
        public async Task throws_exception_with_underscore_in_name()
        {
            var sut = new CapabilityApplicationServiceBuilder()
                      .WithCapabilityRepository(new StubCapabilityRepository())
                      .WithCapabilityFactory(new CapabilityFactory())
                      .Build();

            var dummyName = "A_Name";

            await Assert.ThrowsAsync <CapabilityValidationException>(() => sut.CreateCapability(dummyName, string.Empty));
        }
Esempio n. 6
0
        public async Task adding_a_context_to_a_non_existing_capability_throws_exception()
        {
            var sut = new CapabilityApplicationServiceBuilder()
                      .WithCapabilityRepository(new StubCapabilityRepository())
                      .Build();

            var nonExistingCapabilityId = Guid.Empty;
            var dummyMemberId           = "*****@*****.**";

            await Assert.ThrowsAsync <CapabilityDoesNotExistException>(() => sut.AddContext(nonExistingCapabilityId, dummyMemberId));
        }
Esempio n. 7
0
        public async Task removing_non_existing_member_from_a_capability_throws_exception()
        {
            var capability = new CapabilityBuilder().Build();

            var sut = new CapabilityApplicationServiceBuilder()
                      .WithCapabilityRepository(new StubCapabilityRepository(capability))
                      .Build();

            var nonExistingMemberEmail = "*****@*****.**";

            await Assert.ThrowsAsync <NotMemberOfCapabilityException>(() => sut.LeaveCapability(capability.Id, nonExistingMemberEmail));
        }
Esempio n. 8
0
        public async Task expected_member_is_added_to_capability()
        {
            var capability = new CapabilityBuilder().Build();

            var sut = new CapabilityApplicationServiceBuilder()
                      .WithCapabilityRepository(new StubCapabilityRepository(capability))
                      .Build();

            var stubMemberEmail = "*****@*****.**";

            await sut.JoinCapability(capability.Id, stubMemberEmail);

            Assert.Equal(new[] { stubMemberEmail }, capability.Members.Select(x => x.Email));
        }
Esempio n. 9
0
        public async Task expected_member_is_removed_from_capability()
        {
            var stubMemberEmail = "*****@*****.**";

            var capability = new CapabilityBuilder()
                             .WithMembers(stubMemberEmail)
                             .Build();

            var sut = new CapabilityApplicationServiceBuilder()
                      .WithCapabilityRepository(new StubCapabilityRepository(capability))
                      .Build();

            await sut.LeaveCapability(capability.Id, stubMemberEmail);

            Assert.Empty(capability.Members);
        }
Esempio n. 10
0
        public async Task adding_the_same_member_to_a_capability_multiple_times_yields_single_membership()
        {
            var capability = new CapabilityBuilder().Build();

            var sut = new CapabilityApplicationServiceBuilder()
                      .WithCapabilityRepository(new StubCapabilityRepository(capability))
                      .Build();

            var stubMemberEmail = "*****@*****.**";

            await sut.JoinCapability(capability.Id, stubMemberEmail);

            await sut.JoinCapability(capability.Id, stubMemberEmail);

            Assert.Equal(new[] { stubMemberEmail }, capability.Members.Select(x => x.Email));
        }
Esempio n. 11
0
        public async Task updating_a_non_existing_context_on_an_existing_capability_throws_exception()
        {
            var capability = new CapabilityBuilder()
                             .Build();
            var sut = new CapabilityApplicationServiceBuilder()
                      .WithCapabilityRepository(new StubCapabilityRepository(capability))
                      .Build();

            var nonExistingContextId = Guid.Empty;
            var dummyAccountId       = "111111111111";
            var dummyEmail           = "*****@*****.**";
            var dummyArn             = "mynameisarne";


            await Assert.ThrowsAsync <ContextDoesNotExistException>(() =>
                                                                    sut.UpdateContext(capability.Id, nonExistingContextId, dummyAccountId, dummyArn, dummyEmail));
        }
Esempio n. 12
0
        public async Task updating_a_existing_context_on_an_existing_capability()
        {
            var context    = new Context(Guid.NewGuid(), "default");
            var capability = new CapabilityBuilder()
                             .WithContexts(context)
                             .Build();

            var sut = new CapabilityApplicationServiceBuilder()
                      .WithCapabilityRepository(new StubCapabilityRepository(capability))
                      .Build();

            var newAccountId = "111111111111";
            var newEmail     = "*****@*****.**";
            var newRoleArn   = "mynameisarne";

            await sut.UpdateContext(capability.Id, context.Id, newAccountId, newRoleArn, newEmail);

            var contextFromCapability = capability.Contexts.Single();

            Assert.Equal(contextFromCapability.AWSAccountId, newAccountId);
            Assert.Equal(contextFromCapability.AWSRoleArn, newRoleArn);
            Assert.Equal(contextFromCapability.AWSRoleEmail, newEmail);
        }