public async Task Save_ShouldThrowArgumentNullException_WhenInputIsNull() { Mock <IDynamoDBContext> mock = new Mock <IDynamoDBContext>(); ITokenUserRepository sut = new TokenUserRepository(mock.Object); await Assert.ThrowsAsync <ArgumentNullException>(() => sut.Save(null)); }
public async Task Save_ShouldComplete_WhenInputIsValid() { TokenUser user = new TokenUser() { Id = "abc123" }; Mock <IDynamoDBContext> mock = new Mock <IDynamoDBContext>(); mock.Setup(x => x.SaveAsync <TokenUser>(It.IsAny <TokenUser>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(true)); ITokenUserRepository repository = new TokenUserRepository(mock.Object); await repository.Save(user); mock.Verify(x => x.SaveAsync <TokenUser>(It.IsAny <TokenUser>(), It.IsAny <CancellationToken>()), Times.Once()); }