public void ShouldResolveOnce() { var resolverMock = new Mock <IHostResolver>(); var resolver = new CachingHostResolver(resolverMock.Object, 5000); resolver.Resolve("localhost"); resolver.Resolve("localhost"); resolverMock.Verify(x => x.Resolve("localhost"), Times.Once); }
public void ShouldExpireCached() { var resolverMock = new Mock <IHostResolver>(); var resolver = new CachingHostResolver(resolverMock.Object, 1000); resolver.Resolve("localhost"); Thread.Sleep(1500); resolver.Resolve("localhost"); resolverMock.Verify(x => x.Resolve("localhost"), Times.Exactly(2)); }
public async void ShouldResolveOnceMixedSyncFirst() { var resolverMock = new Mock <IHostResolver>(); var resolver = new CachingHostResolver(resolverMock.Object, 5000); resolver.Resolve("localhost"); await resolver.ResolveAsync("localhost"); resolver.Resolve("localhost"); await resolver.ResolveAsync("localhost"); resolverMock.Verify(x => x.Resolve("localhost"), Times.Once); }