public void TestGetServerWhenCached() { var existing = new WhoisServer("com", "server.com"); cache.Set(existing); var server = cache.Get("com"); Assert.AreEqual(existing, server); }
public void TestCacheUpdate() { var first = new WhoisServer("com", "second.com"); cache.Set(first); var second = new WhoisServer("com", "second.com"); cache.Set(second); var server = cache.Get("com"); Assert.AreEqual(second, server); }
public async Task <WhoisServer> LookupAsync(string tld) { var content = await GetWhoisServerResponse(tld); // Reflect the raw response onto a ParsedWhoisServer object var parsed = new Tokenizer() .Parse <ParsedWhoisServer>(Embedded.Patterns.Servers.Iana, content); var response = new WhoisServer(tld, parsed.Url); response.Content = content; response.ParsedWhoisServer = parsed; return(response); }
public void Set(WhoisServer server) { cache.AddOrUpdate(server.Tld, server, (tld, existing) => server); }