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); }
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); }