Ejemplo n.º 1
0
        public void ShouldBuildPostHttpMethod()
        {
            // arrange
            const string url        = "http://fakeurl/";
            var          httpClient = new MockedHttpClient();
            IHttpClientVerbBuilder <MockedHttpClient> builder = new HttpClientVerbBuilder <MockedHttpClient>(httpClient);

            // act
            IHttpClientQueryBuilder queryBuilder = builder.Post(url);

            // assert
            Assert.Matches(queryBuilder.HttpMethod.Method, "POST");
        }
Ejemplo n.º 2
0
        public void ShouldBuildPostHttpMethodWithPayload()
        {
            // arrange
            const string url     = "http://fakeurl/";
            var          payload = new FakePayload
            {
                Id = 10,
                NonNullDateTime  = new DateTime(2010, 1, 1, 10, 00, 00),
                Note             = "Note1",
                NullableDateTime = new DateTime(2012, 1, 1, 1, 0, 0, 0),
                Token            = Guid.NewGuid()
            };
            var httpClient = new MockedHttpClient();
            IHttpClientVerbBuilder <MockedHttpClient> builder = new HttpClientVerbBuilder <MockedHttpClient>(httpClient);

            // act
            IHttpClientQueryBuilder queryBuilder = builder.Post(url, new JsonContent(payload));

            // assert
            Assert.NotNull(queryBuilder.Content);
            Assert.Matches(queryBuilder.HttpMethod.Method, "POST");
            JsonContent content = Assert.IsType <JsonContent>(queryBuilder.Content);
        }