コード例 #1
0
        public void RestTestPost()
        {
            var restApi = TestDataProvider.GetData <BasePost>("BasePost");

            rest = new ClientCreator().CreateClient(ApiPosts);
            var request  = rest.PostRequest(restApi);
            var response = rest.GetResponse(rest, request);
            var content  = rest.GetContent <BasePost>(response);

            Assert.AreEqual(restApi.Text, content.Text);
            Assert.AreEqual(restApi.Title, content.Title);
            Assert.That(response.ContentType, Is.EqualTo("application/json; charset=utf-8"));
        }
コード例 #2
0
        public void RestTestPut()
        {
            var RestApi = TestDataProvider.GetData <PostInfo>("PutInfo");

            rest = new ClientCreator().CreateClient(ApiPosts);
            var request  = rest.PutRequest(RestApi);
            var response = rest.GetResponse(rest, request);
            var content  = rest.GetContent <PostInfo>(response);

            Assert.AreEqual(RestApi.Id, content.Id);
            Assert.AreEqual(RestApi.Rate, content.Rate);
            Assert.AreEqual(RestApi.Text, content.Text);
            Assert.AreEqual(RestApi.Title, content.Title);
            Assert.That(response.IsSuccessful);
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
        }
コード例 #3
0
        public void RestTestGetById()
        {
            var restApi = TestDataProvider.GetData <PostInfo>("PostInfo");

            rest = new ClientCreator().CreateClient($"{ApiPosts}/{restApi.Id}");
            var request  = rest.GetRequest();
            var response = rest.GetResponse(rest, request);
            var content  = rest.GetContent <PostInfo>(response);

            Assert.AreEqual(restApi.Id, content.Id);
            Assert.AreEqual(restApi.Rate, content.Rate);
            Assert.AreEqual(restApi.Text, content.Text);
            Assert.AreEqual(restApi.Title, content.Title);
            Assert.That(response.ContentType, Is.EqualTo("application/json; charset=utf-8"));
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
        }