コード例 #1
0
        public async Task Handle_GroupNotFound_ReturnsNull()
        {
            //Arrange
            var fakeAmazonIdentityManagementService = Substitute.For <IAmazonIdentityManagementService>();

            fakeAmazonIdentityManagementService
            .GetGroupAsync(Arg.Is <GetGroupRequest>(args => args.GroupName == "some-group-name"))
            .Throws(new NoSuchEntityException("dummy"));

            var handler = new GetAmazonGroupByNameQueryHandler(
                fakeAmazonIdentityManagementService);

            //Act
            var group = await handler.Handle(new GetAmazonGroupByNameQuery("some-group-name"), default);

            //Assert
            Assert.IsNull(group);
        }
コード例 #2
0
        public async Task Handle_GroupFound_ReturnsFoundGroup()
        {
            //Arrange
            var fakeAmazonIdentityManagementService = Substitute.For <IAmazonIdentityManagementService>();

            fakeAmazonIdentityManagementService
            .GetGroupAsync(Arg.Is <GetGroupRequest>(args => args.GroupName == "some-group-name"))
            .Returns(new GetGroupResponse()
            {
                Group = new Group()
            });

            var handler = new GetAmazonGroupByNameQueryHandler(
                fakeAmazonIdentityManagementService);

            //Act
            var group = await handler.Handle(new GetAmazonGroupByNameQuery("some-group-name"), default);

            //Assert
            Assert.IsNotNull(group);
        }