public async Task Load_ShouldThrowArgumentNullException_WhenInputIsNull(string id) { Mock <IDynamoDBContext> mock = new Mock <IDynamoDBContext>(); ITokenUserRepository sut = new TokenUserRepository(mock.Object); await Assert.ThrowsAsync <ArgumentNullException>(() => sut.Load(id)); }
public async Task Load_ShouldComplete_WhenInputIsValid() { TokenUser expectedUser = new TokenUser() { Id = "abc123" }; Mock <IDynamoDBContext> mock = new Mock <IDynamoDBContext>(); mock.Setup(x => x.LoadAsync <TokenUser>(It.IsAny <string>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(expectedUser)); ITokenUserRepository repository = new TokenUserRepository(mock.Object); TokenUser user = await repository.Load(expectedUser.Id); mock.Verify(x => x.LoadAsync <TokenUser>(It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Once()); Assert.IsType <TokenUser>(user); Assert.Equal(expectedUser, user); }