public async Task Execute_WhenRefreshTokenIsNull_ShouldFail() { var useCase = new RenewTokenUseCase(secureServiceMock.Object, cacheServiceMock.Object); useCase.RefreshToken = null; var result = await useCase.Execute(); Assert.IsTrue(result.DidFail); secureServiceMock.Verify(service => service.RenewToken(It.IsAny <string>()), Times.Never); }
public async Task Execute_Should_RenewToken() { cacheServiceMock.Setup(cache => cache.SetValue(KEYS.REFRESH_TOKEN, It.IsAny <string>())) .Verifiable(); cacheServiceMock.Setup(cache => cache.GetValue <string>(KEYS.REFRESH_TOKEN)) .Returns(TestDoubles.RefreshToken); secureServiceMock.Setup(service => service.RenewToken(It.IsAny <string>())) .Returns(Task.FromResult(TestDoubles.authResult)) .Verifiable(); var useCase = new RenewTokenUseCase(secureServiceMock.Object, cacheServiceMock.Object); var result = await useCase.Execute(); Assert.IsTrue(result.DidSucceed); secureServiceMock.Verify(service => service.RenewToken(It.IsAny <string>()), Times.Once); }