public void GolfClubCommandHandler_HandleCommand_RequestClubMembershipCommand_CommandHandled() { Mock <IAggregateRepository <GolfClubAggregate> > repository = new Mock <IAggregateRepository <GolfClubAggregate> >(); Mock <ISecurityService> oAuth2SecurityService = new Mock <ISecurityService>(); Mock <IGolfClubMembershipApplicationService> golfClubMembershipApplicationService = new Mock <IGolfClubMembershipApplicationService>(); golfClubMembershipApplicationService.Setup(x => x.RequestClubMembership(It.IsAny <Guid>(), It.IsAny <Guid>(), CancellationToken.None)) .Returns(Task.CompletedTask); GolfClubCommandHandler handler = new GolfClubCommandHandler(repository.Object, oAuth2SecurityService.Object, golfClubMembershipApplicationService.Object); RequestClubMembershipCommand command = GolfClubTestData.GetRequestClubMembershipCommand(); Should.NotThrow(async() => { await handler.Handle(command, CancellationToken.None); }); }
public void GolfClubCommandHandler_HandleCommand_CreateMatchSecretaryCommand_CommandHandled() { Mock <IAggregateRepository <GolfClubAggregate> > repository = new Mock <IAggregateRepository <GolfClubAggregate> >(); repository.Setup(r => r.GetLatestVersion(It.IsAny <Guid>(), CancellationToken.None)).ReturnsAsync(GolfClubTestData.GetCreatedGolfClubAggregate); Mock <ISecurityService> oAuth2SecurityService = new Mock <ISecurityService>(); Mock <IGolfClubMembershipApplicationService> golfClubMembershipApplicationService = new Mock <IGolfClubMembershipApplicationService>(); GolfClubCommandHandler handler = new GolfClubCommandHandler(repository.Object, oAuth2SecurityService.Object, golfClubMembershipApplicationService.Object); oAuth2SecurityService .Setup(o => o.RegisterUser(It.IsAny <RegisterUserRequest>(), CancellationToken.None)) .ReturnsAsync(GolfClubTestData.GetRegisterUserResponse()); CreateMatchSecretaryCommand command = GolfClubTestData.GetCreateMatchSecretaryCommand(); Should.NotThrow(async() => { await handler.Handle(command, CancellationToken.None); }); }