public void UserWasUpdatedAfterPatchRequest()
        {
            string collection = "users";
            var    client     = HttpTool.CreateClient(BaseAddressUri, AcceptHeader);

            AddCleanupAction(() => client.Dispose());
            var newUserId = HttpTool.CreateAndPostRandomUser(BaseAddressUri, AcceptHeader);

            AddCleanupAction(() => HttpTool.DeleteUser(client, newUserId));
            var newUserFromServer = HttpTool.GetUserById(client, newUserId);
            var newUserName       = $"Updated {newUserFromServer.Name}";

            newUserFromServer.Name = newUserName;
            var updatedUser = new User {
                Id = newUserId, Name = newUserName
            };
            string uriRequestPatch = $"api/{collection}/{newUserId}";

            HttpContent   httpContent = HttpTool.ConvertObjectToHttpContent((UserDTO)updatedUser);
            var           httpResponseMessagePatch = HttpTool.MakeRequestToServer(client, HttpMethod.Patch, uriRequestPatch, httpContent);
            Task <string> readTask = HttpTool.ReadContentFromMessage(httpResponseMessagePatch);

            var updatedUserFromServer = HttpTool.GetUserById(client, newUserId);

            Assert.IsTrue(updatedUserFromServer.Equals(newUserFromServer), $"The User in the Response is not the expected one!");
        }
        public void ResponseContainsUserAfterUserIsCreated()
        {
            // DEMO 01: Creation of random User
            var randomNumber   = new Random().Next(1000, 9999);
            var randomUserName = $"RandomUser{randomNumber}";
            var newUser        = new User {
                Name = randomUserName, Age = 20, Location = "NY", Work = new Work()
                {
                    Name = "Sela", Location = "BB", Rating = 5
                }
            };

            string collection     = "users";
            string uriRequestPost = $"api/{collection}";

            // DEMO 02: HTTP Client Creation - with URI and Headers
            var client = HttpTool.CreateClient(BaseAddressUri, AcceptHeader);

            AddCleanupAction(() => client.Dispose());
            // DEMO 05: Serialization of Json Object
            HttpContent httpContent = HttpTool.ConvertObjectToHttpContent((UserDTO)newUser);

            // DEMO 08: Client makes Request to server, by providing Method, URI and HttpContent
            var httpResponseMessagePost = HttpTool.MakeRequestToServer(client, HttpMethod.Post, uriRequestPost, httpContent);

            // DEMO 13: Deserialization by specific Class, if I want to crop any specific data from large Json Object.
            var responseUserAfterPost = HttpTool.DeserializeFromResponseMessage <JsonResponseUserId>(httpResponseMessagePost);
            //var responseUserAfterPost = HttpTool.DeserializeFromResponseMessage<User>(httpResponseMessagePost);
            var responsedUserId = responseUserAfterPost.Id;

            AddCleanupAction(() => HttpTool.DeleteUser(client, responsedUserId));

            // DEMO 16: Making of GET Request, to get the User just created
            var uriRequestGet = $"api/{collection}/{responsedUserId}";

            var httpResponseMessageGet = HttpTool.MakeRequestToServer(client, HttpMethod.Get, uriRequestGet);
            // DEMO 17: Deserialization by specific Class, this time by User
            var userAfterGet = HttpTool.DeserializeFromResponseMessage <User>(httpResponseMessageGet);

            // DEMO 18: Compare between users - [User after Get Request from the Server] vs. [User created in the beginning]
            Assert.IsTrue(userAfterGet.Equals(newUser), $"The User in the Response is not the expected one!");
        }