public async Task Save_ShouldThrowArgumentNullException_WhenTokenUserIsNull() { TokenUser expectedTokenUser = new TokenUser() { Id = "TestId" }; Mock <ILogger <TokenUserData> > mockLogger = new Mock <ILogger <TokenUserData> >(); Mock <ITokenUserRepository> mockTokenUserRepository = new Mock <ITokenUserRepository>(); mockTokenUserRepository.Setup(x => x.Save(It.IsAny <TokenUser>())).Returns(Task.FromResult(true)); TokenUserData sut = new TokenUserData(mockLogger.Object, mockTokenUserRepository.Object); await Assert.ThrowsAsync <ArgumentNullException>(() => sut.Save(null)); }
public async Task Save_ShouldReturn_WhenTokenUserUsValid() { TokenUser expectedTokenUser = new TokenUser() { Id = "TestId" }; Mock <ILogger <TokenUserData> > mockLogger = new Mock <ILogger <TokenUserData> >(); Mock <ITokenUserRepository> mockTokenUserRepository = new Mock <ITokenUserRepository>(); mockTokenUserRepository.Setup(x => x.Save(It.IsAny <TokenUser>())).Returns(Task.FromResult(true)); TokenUserData sut = new TokenUserData(mockLogger.Object, mockTokenUserRepository.Object); await sut.Save(expectedTokenUser); mockTokenUserRepository.Verify(x => x.Save(expectedTokenUser), Times.Once()); }