public void WhenNoResponseRecordedEmptyIsReturned() { var proxy = new ServerResponseProxy(); var response = proxy.GetResponseText(Some.ApiKey()); Assert.Equal("{}", response); }
public void WhenApiKeysDontMatchEmptyResponseReturned() { var proxy = new ServerResponseProxy(); proxy.SuccessResponseReturned(Some.ApiKey(), "this is never used"); var response = proxy.GetResponseText(Some.ApiKey()); Assert.Equal("{}", response); }
public void WhenApiKeysMatchTheResponseIsReturned() { var proxy = new ServerResponseProxy(); var apiKey = Some.ApiKey(); var responseText = "some response"; proxy.SuccessResponseReturned(apiKey, responseText); var response = proxy.GetResponseText(apiKey); Assert.Equal(responseText, response); }
public void ApiKeySpecificBuffersWriteDataToSubfolders() { using (var tmp = new TempFolder("Buffer")) using (var map = CreateActiveLogBufferMap(tmp)) { string key1 = Some.ApiKey(), key2 = Some.ApiKey(); var entry1 = map.GetLogBuffer(key1); var entry2 = map.GetLogBuffer(key2); Assert.NotNull(entry1); Assert.NotNull(entry2); Assert.Same(entry1, map.GetLogBuffer(key1)); Assert.NotSame(entry1, entry2); var subdirs = Directory.GetDirectories(tmp.Path); Assert.Equal(2, subdirs.Length); Assert.True(File.Exists(Path.Combine(subdirs[0], "data.mdb"))); Assert.True(File.Exists(Path.Combine(subdirs[0], ".apikey"))); } }
public void EntriesSurviveReloads() { var apiKey = Some.ApiKey(); var value = Some.Bytes(100); using (var tmp = new TempFolder("Buffer")) { using (var map = CreateActiveLogBufferMap(tmp)) { map.GetLogBuffer(null).Enqueue(new[] { value }); map.GetLogBuffer(apiKey).Enqueue(new[] { value }); } using (var map = CreateActiveLogBufferMap(tmp)) { var first = map.GetLogBuffer(null).Peek(0).Single(); var second = map.GetLogBuffer(apiKey).Peek(0).Single(); Assert.Equal(value, first.Value); Assert.Equal(value, second.Value); } } }