Пример #1
0
        public void WhenNoResponseRecordedEmptyIsReturned()
        {
            var proxy    = new ServerResponseProxy();
            var response = proxy.GetResponseText(Some.ApiKey());

            Assert.Equal("{}", response);
        }
Пример #2
0
        public void WhenApiKeysDontMatchEmptyResponseReturned()
        {
            var proxy = new ServerResponseProxy();

            proxy.SuccessResponseReturned(Some.ApiKey(), "this is never used");
            var response = proxy.GetResponseText(Some.ApiKey());

            Assert.Equal("{}", response);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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")));
                }
        }
Пример #5
0
        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);
                }
            }
        }