public async Task TestDeserializeCalledWithResponseBodyAsync()
        {
            var response     = new Response(0, Encoding.ASCII.GetBytes("Hello, World!"));
            var mockSender   = new MockSender(response);
            var deserializer = new FakeDeserializer(null);
            var client       = new Client(mockSender, deserializer);

            await client.SendAsync(new Lookup("1", "2"));

            Assert.AreEqual(response.Payload, deserializer.Payload);
        }
        public void TestDeserializeCalledWithResponseBody()
        {
            var response     = new Response(0, Encoding.ASCII.GetBytes("Hello, world!"));
            var sender       = new MockSender(response);
            var deserializer = new FakeDeserializer(null);
            var client       = new Client(sender, deserializer);

            client.Send(new Lookup());

            Assert.AreEqual(response.Payload, deserializer.Payload);
        }
        public async Task TestDeserializeCalledWithResponseBodyAsync()
        {
            var response     = new Response(0, Encoding.ASCII.GetBytes("Hello, World!"));
            var mockSender   = new MockSender(response);
            var sender       = new URLPrefixSender("http://localhost/", mockSender);
            var deserializer = new FakeDeserializer(new Result());
            var client       = new Client(sender, deserializer);

            await client.SendAsync(new Lookup("1"));

            Assert.AreEqual(response.Payload, deserializer.Payload);
        }
Beispiel #4
0
        public void TestResultCorrectlyAssignedToCorrespondingLookup()
        {
            var expectedResult = new Result();
            var lookup         = new Lookup("Hello, World!");

            var sender       = new MockSender(new Response(0, Encoding.ASCII.GetBytes("[]")));
            var deserializer = new FakeDeserializer(expectedResult);
            var client       = new Client(sender, deserializer);

            client.Send(lookup);

            Assert.AreEqual(expectedResult, lookup.Result);
        }
        public async Task TestResultCorrectlyAssignedToLookupAsync()
        {
            var lookup         = new Lookup("1");
            var expectedResult = new Result();

            var mockSender   = new MockSender(new Response(0, Encoding.ASCII.GetBytes("{[]}")));
            var sender       = new URLPrefixSender("http://localhost/", mockSender);
            var deserializer = new FakeDeserializer(expectedResult);
            var client       = new Client(sender, deserializer);

            await client.SendAsync(lookup);

            Assert.AreEqual(expectedResult.Suggestions, lookup.Result);
        }
        public async Task TestCandidatesCorrectlyAssignedToLookupAsync()
        {
            var expectedCandidates = new List <Candidate> {
                new Candidate(), new Candidate()
            };
            var lookup = new Lookup("1", "2");

            var mockSender   = new MockSender(new Response(0, Encoding.ASCII.GetBytes("[]")));
            var deserializer = new FakeDeserializer(expectedCandidates);
            var client       = new Client(mockSender, deserializer);

            await client.SendAsync(lookup);

            Assert.AreEqual(expectedCandidates[0], lookup.Result[0]);
            Assert.AreEqual(expectedCandidates[1], lookup.Result[1]);
        }
Beispiel #7
0
        public void TestCandidatesCorrectlyAssignedToLookup()
        {
            var expectedCandidates = new Candidate[2];

            expectedCandidates[0] = new Candidate();
            expectedCandidates[1] = new Candidate();
            var lookup = new Lookup("1", "2");

            var mockSender   = new MockSender(new Response(0, Encoding.ASCII.GetBytes("[]")));
            var deserializer = new FakeDeserializer(expectedCandidates);
            var client       = new Client(mockSender, deserializer);

            client.Send(lookup);

            Assert.AreEqual(expectedCandidates[0], lookup.Result[0]);
            Assert.AreEqual(expectedCandidates[1], lookup.Result[1]);
        }
        public void TestCandidatesCorrectlyAssignedToCorrespondingLookup()
        {
            var expectedCandidates = new List <Candidate> {
                new Candidate(0), new Candidate(1), new Candidate(1)
            };
            var batch = new Batch {
                new Lookup(), new Lookup()
            };

            var sender       = new MockSender(new Response(0, new byte[0]));
            var deserializer = new FakeDeserializer(expectedCandidates);
            var client       = new Client(sender, deserializer);

            client.Send(batch);

            Assert.AreEqual(expectedCandidates[0], batch[0].Result[0]);
            Assert.AreEqual(expectedCandidates[1], batch[1].Result[0]);
            Assert.AreEqual(expectedCandidates[2], batch[1].Result[1]);
        }
        public async Task TestCandidatesCorrectlyAssignedToCorrespondingLookupAsync()
        {
            var expectedResults = new Result[2];

            expectedResults[0] = new Result();
            expectedResults[1] = new Result();
            var batch = new Batch {
                new Lookup(), new Lookup()
            };

            var sender       = new MockSender(new Response(0, new byte[0]));
            var deserializer = new FakeDeserializer(expectedResults);
            var client       = new Client(sender, deserializer);

            await client.SendAsync(batch);

            Assert.AreEqual(expectedResults[0], batch[0].Result);
            Assert.AreEqual(expectedResults[1], batch[1].Result);
        }
Beispiel #10
0
        public void TestCandidatesCorrectlyAssignedToCorrespondingLookup()
        {
            var expectedResults = new Result[2];

            expectedResults[0] = new Result();
            expectedResults[1] = new Result();
            var batch = new Batch();

            batch.Add(new Lookup());
            batch.Add(new Lookup());

            var sender       = new MockSender(new Response(0, new byte[0]));
            var deserializer = new FakeDeserializer(expectedResults);
            var client       = new Client("/", sender, deserializer);

            client.Send(batch);

            Assert.AreEqual(expectedResults[0], batch[0].Result);
            Assert.AreEqual(expectedResults[1], batch[1].Result);
        }
Beispiel #11
0
        public async Task TestCandidatesCorrectlyAssignedToCorrespondingLookupAsync()
        {
            var expectedCandidates = new Candidate[3];

            expectedCandidates[0] = new Candidate(0);
            expectedCandidates[1] = new Candidate(1);
            expectedCandidates[2] = new Candidate(1);
            var batch = new Batch();

            batch.Add(new Lookup());
            batch.Add(new Lookup());

            var sender       = new MockSender(new Response(0, new Byte[0]));
            var deserializer = new FakeDeserializer(expectedCandidates);
            var client       = new Client("/", sender, deserializer);

            await client.SendAsync(batch);

            Assert.AreEqual(expectedCandidates[0], batch[0].Result[0]);
            Assert.AreEqual(expectedCandidates[1], batch[1].Result[0]);
            Assert.AreEqual(expectedCandidates[2], batch[1].Result[1]);
        }