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

            AddCleanupAction(() => client.Dispose());
            var    newUserId        = HttpTool.CreateAndPostRandomUser(BaseAddressUri, AcceptHeader);
            string uriRequestDelete = $"api/{collection}/{newUserId}";

            var           httpResponseMessageDelete = HttpTool.MakeRequestToServer(client, HttpMethod.Delete, uriRequestDelete);
            Task <string> readTask = HttpTool.ReadContentFromMessage(httpResponseMessageDelete);

            var httpResponseMessage = HttpTool.EnsureObjectIsNotFound(client, uriRequestDelete);

            Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.NotFound, $"The User was not deleted as expected!");
        }
        public void PostAndDeleteUsersInLoop()
        {
            for (int i = 0; i < 100; i++)
            {
                // Post
                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}";

                var client = HttpTool.CreateClient(BaseAddressUri, AcceptHeader);
                AddCleanupAction(() => client.Dispose());
                HttpContent httpContent = HttpTool.ConvertObjectToHttpContent((UserDTO)newUser);

                var httpResponseMessagePost = HttpTool.MakeRequestToServer(client, HttpMethod.Post, uriRequestPost, httpContent);
                var responseUserAfterPost   = HttpTool.DeserializeFromResponseMessage <User>(httpResponseMessagePost);
                var responsedUserId         = responseUserAfterPost.Id;

                var uriRequestGet = $"api/{collection}/{responsedUserId}";

                var httpResponseMessageGet = HttpTool.MakeRequestToServer(client, HttpMethod.Get, uriRequestGet);
                var userAfterGet           = HttpTool.DeserializeFromResponseMessage <User>(httpResponseMessageGet);
                Assert.IsTrue(userAfterGet.Equals(newUser), $"The User in the Response is not the expected one!");

                // Delete
                var    userId           = userAfterGet.Id;
                string uriRequestDelete = $"api/{collection}/{userId}";

                var           httpResponseMessageDelete = HttpTool.MakeRequestToServer(client, HttpMethod.Delete, uriRequestDelete);
                Task <string> readTask = HttpTool.ReadContentFromMessage(httpResponseMessageDelete);

                var httpResponseMessage = HttpTool.EnsureObjectIsNotFound(client, uriRequestDelete);

                Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.NotFound, $"The User was not deleted as expected!");
            }
        }