public async void ShouldResolveOnceAsync() { var resolverMock = new Mock <IHostResolver>(); var resolver = new CachingHostResolver(resolverMock.Object, 5000); await resolver.ResolveAsync("localhost"); await resolver.ResolveAsync("localhost"); resolverMock.Verify(x => x.ResolveAsync("localhost"), Times.Once); }
public async void ShouldExpireCachedAsync() { var resolverMock = new Mock <IHostResolver>(); var resolver = new CachingHostResolver(resolverMock.Object, 1000); await resolver.ResolveAsync("localhost"); await Task.Delay(1500); await resolver.ResolveAsync("localhost"); resolverMock.Verify(x => x.ResolveAsync("localhost"), Times.Exactly(2)); }