예제 #1
0
    public async void Handle_GivenValidRegistrationDetails_ShouldSucceed()
    {
        // arrange

        // 1. We need to store the user data somehow
        var mockUserRepository = new Mock <IUserRepository>();

        mockUserRepository
        .Setup(repo => repo.Delete(It.IsAny <string>()))
        .ReturnsAsync(new DTO.GatewayResponses.Repositories.DeleteUserResponse("", true));

        // 2. The use case and star of this test
        var useCase = new DeleteUserUseCase(mockUserRepository.Object);

        // 3. The output port is the mechanism to pass response data from the use case to a Presenter
        // for final preparation to deliver back to the UI/web page/api response etc.
        var mockOutputPort = new Mock <IOutputPort <UseCaseResponseMessage> >();

        mockOutputPort.Setup(outputPort => outputPort.Handle(It.IsAny <UseCaseResponseMessage>()));

        // act

        // 4. We need a request model to carry data into the use case from the upper layer (UI, Controller etc.)
        var response = await useCase.Handle(new DeleteUserRequest("userName"), mockOutputPort.Object);

        // assert
        Assert.True(response);
        mockUserRepository.VerifyAll();
        mockOutputPort.VerifyAll();
    }
예제 #2
0
 internal UserUseCaseFactory(ISecurityGateway securityGateway, IRepositoryFactory repositoryFactory)
 {
     ChangeInformation = new ChangeInformationUseCase(securityGateway, repositoryFactory.UserRepository);
     ChangePassword    = new ChangePasswordUseCase(securityGateway, repositoryFactory.UserRepository);
     DeleteUser        = new DeleteUserUseCase(securityGateway, repositoryFactory.UserRepository);
     RegisterUser      = new RegisterUserUseCase(securityGateway, repositoryFactory.UserRepository);
     ViewProfile       = new ViewProfileUseCase(securityGateway, repositoryFactory.UserRepository);
     AuthorizeUser     = new AuthorizeUserUseCase(securityGateway, repositoryFactory.UserRepository);
 }
예제 #3
0
 public void TestInitialize()
 {
     _userRepositoryMock = new Mock <IUserRepository>();
     _outputPortMock     = new Mock <IOutputPort <Response <User> > >();
     _deleteUserUseCase  = new DeleteUserUseCase(_userRepositoryMock.Object);
 }