Пример #1
0
        public void WhenIPostCreateUserRequest()
        {
            RestAPIHelpers apiHelper = new RestAPIHelpers();
            RestClient     client    = new RestClient(url);
            RestRequest    request   = apiHelper.CreatePostRequest(newUserData);

            response = client.Execute(request);
        }
        public void CreateNewUserTest()
        {
            //Arrange
            var url = "https://reqres.in/api/users";
            UserRequestJsonModel newUserData = new UserRequestJsonModel()
            {
                name = "morpheus",
                job  = "developer"
            };

            RestAPIHelpers apiHelper = new RestAPIHelpers();
            RestClient     client    = new RestClient(url);
            RestRequest    request   = apiHelper.CreatePostRequest(newUserData);

            //Act
            IRestResponse response = client.Execute(request);
            var           result   = JsonConvert.DeserializeObject <CreateUserResponseJSonModel>(response.Content.ToString());

            //Assert
            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, "New user creation Failed");
            Assert.IsTrue(((result.name == newUserData.name) && (result.job == newUserData.job)), "Created User is different");
        }