Exemplo n.º 1
0
        public async Task ExecutePostAsync()
        {
            // Arrange
            const string expectedResponseMessage = "Item created";
            const int expectedResponseCode = 200;

            var request = new RestRequest(HttpVerb.Post, "RestArt", this._headers, this._parameters);

            // Act
            IRestResponse<TestResponse> response = await this._client.ExecuteAsync<TestResponse>(request);

            // Assert
            Assert.NotNull(response);
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.NotNull(response.Raw);
            Assert.NotNull(response.Value);
            Assert.Equal(expectedResponseCode, response.Value.Code);
            Assert.Equal(expectedResponseMessage, response.Value.Msg);
        }
Exemplo n.º 2
0
        public async Task ExecutePostWithObjectsAsync()
        {
            // Arrange
            const string expectedResponseMessage = "Item created";
            const int expectedResponseCode = 200;

            var parameters = new {
                StringParam = "Some String",
                BoolParam = true,
                IntParam = 42,
                FloatParam = 77.7f
            };

            var headers = new {
                Header1 = "Test-One",
                Header2 = "Test-Two"
            };

            var request = new RestRequest(HttpVerb.Post, "RestArt", headers, parameters);

            // Act
            IRestResponse<TestResponse> response = await this._client.ExecuteAsync<TestResponse>(request);

            // Assert
            Assert.NotNull(response);
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.NotNull(response.Raw);
            Assert.NotNull(response.Value);
            Assert.Equal(expectedResponseCode, response.Value.Code);
            Assert.Equal(expectedResponseMessage, response.Value.Msg);
        }