Beispiel #1
0
        public void TestCustomExtract()
        {
            // Use mocked API client
            using (var client = GetMockedAPIClient())
            {
                // Arrange mocks for custom result
                client.ArrangeWebResponseResultMocks(new MockErrorResultWebResponseConfig());

                // Extract body handler
                var extractBodyFn = new Func <HttpWebResponse, dynamic>(response => response.GetResponseContent());

                // Make client call
                string result = client.Get("/bar", QueryParams.Empty(), extractBodyFn);

                // Assertions
                result.Should().Be("{\"error\":\"errormessage\"}");
            }
        }
Beispiel #2
0
        public void TestHostOverride()
        {
            // Use mocked API client
            using (var client = GetMockedAPIClient())
            {
                // Arrange mocks for custom result
                var webMocks = client.ArrangeWebResponseValidResultsMocks();

                // Set expectations
                webMocks.WebRequestUtil.Expect(
                    x =>
                    x.Get(Arg <string> .Matches(value => value.StartsWith("https://foo.com")),
                          Arg <RequestConfig> .Is.Anything)).CallOriginalMethod(OriginalCallOptions.CreateExpectation);

                // Make client call
                client.Get("/bar", QueryParams.Empty(), baseUrl: "https://foo.com");

                // Assertions
                webMocks.WebRequestUtil.VerifyAllExpectations();
            }
        }