public async Task StoreAnEntry() { //arrange const string longUrl = "a long url"; const string shortUrlKey = "a short url key"; var expireOn = new DateTime(2019, 7, 1, 8, 13, 10); int epochSeconds = AWSSDKUtils.ConvertToUnixEpochSeconds(expireOn); var dynamoDBContextMock = new Mock <IDynamoDBContext>(); var sut = new ToShortUrlRepository(dynamoDBContextMock.Object); //act await sut.Store(longUrl, shortUrlKey, expireOn); //assert dynamoDBContextMock .Verify( m => m.SaveAsync( It.Is <ToShortUrl>(u => u.ShortUrlKey == shortUrlKey && u.LongUrl == longUrl && u.ExpireOn == epochSeconds.ToString()), It.IsAny <CancellationToken>()), Times.Once);; }
public async Task FetchNonExistingLongUrl() { //arrange const string longUrl = "a long url"; var dynamoDBContextMock = new Mock <IDynamoDBContext>(); dynamoDBContextMock .Setup(m => m.LoadAsync <ToShortUrl>(longUrl, It.IsAny <CancellationToken>())) .ReturnsAsync(null as ToShortUrl); var sut = new ToShortUrlRepository(dynamoDBContextMock.Object); //act var actual = await sut.FetchShortUrlKey(longUrl); //assert actual.Should().BeNull(); }