Example #1
0
        public async Task Handle_InvalidToken_ShouldFailed()
        {
            var mockEmailTokenReposytory = new Mock <IEmailTokenReposytory>();

            mockEmailTokenReposytory.Setup(repo => repo.GetToken(It.IsAny <string>())).ReturnsAsync((EmailConfirmToken)null);

            var useCase = new VerifyEmailTokenUseCase(mockEmailTokenReposytory.Object, null);
            var result  = await useCase.Handle(new VerifyEmailTokenRequest(""), _mockOutputPort.Object);

            Assert.False(result);
        }
Example #2
0
        public async Task Handle_ValidToken_ShouldSucceed()
        {
            var mockEmailTokenReposytory = new Mock <IEmailTokenReposytory>();

            mockEmailTokenReposytory.Setup(repo => repo.GetToken(It.IsAny <string>())).ReturnsAsync(new EmailConfirmToken("", 0));

            _mockUserReposytory.Setup(repo => repo.GetById(It.IsAny <long>())).ReturnsAsync(new User("", "", "", "", ""));
            _mockUserReposytory.Setup(repo => repo.ConfirmEmail(It.IsAny <User>())).ReturnsAsync(true);

            var useCase = new VerifyEmailTokenUseCase(mockEmailTokenReposytory.Object, _mockUserReposytory.Object);
            var result  = await useCase.Handle(new VerifyEmailTokenRequest(""), _mockOutputPort.Object);

            Assert.True(result);
        }