public void PatchUserPassword_Valid()
        {
            UserPw temp = new UserPw {
                Name = "User 2", Password = "******"
            };
            var json = JsonSerializer.Serialize(temp);
            var data = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = Client.PatchAsync("patchUserPassword", data).Result;

            Console.WriteLine("StatusCode: " + response.StatusCode + "\n");
            Assert.IsTrue(response.IsSuccessStatusCode);
            Thread.Sleep(200);

            UserPw temp3 = new UserPw {
                Name = "User 2", Password = "******"
            };

            json     = JsonSerializer.Serialize(temp3);
            data     = new StringContent(json, Encoding.UTF8, "application/json");
            response = Client.PostAsync("validateUser", data).Result;
            Assert.IsFalse(response.IsSuccessStatusCode);
            temp3 = new UserPw {
                Name = "User 2", Password = "******"
            };
            json     = JsonSerializer.Serialize(temp3);
            data     = new StringContent(json, Encoding.UTF8, "application/json");
            response = Client.PostAsync("validateUser", data).Result;
            Assert.IsTrue(response.IsSuccessStatusCode);
            if (response.IsSuccessStatusCode)
            {
                User res = (User)JsonSerializer.Deserialize(response.Content.ReadAsStringAsync().Result, typeof(User));
                Console.WriteLine(res);
                Assert.IsTrue(res.Name.Equals(temp.Name));
            }
        }
        public void RegisterUser_AlreadyExists()
        {
            UserPw temp = new UserPw {
                Name = "User 1", Password = "******"
            };
            var json = JsonSerializer.Serialize(temp);
            var data = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = Client.PostAsync("registerUser", data).Result;

            Console.WriteLine("StatusCode: " + response.StatusCode + "\n");
            Assert.IsFalse(response.IsSuccessStatusCode);
        }
        public void PatchUserPassword_NotFound()
        {
            UserPw temp = new UserPw {
                Name = "User 3", Password = "******"
            };
            var json = JsonSerializer.Serialize(temp);
            var data = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = Client.PatchAsync("patchUserPassword", data).Result;

            Console.WriteLine("StatusCode: " + response.StatusCode + "\n");
            Assert.IsFalse(response.IsSuccessStatusCode);
        }
        public async Task <User> RegisterUser(UserPw userPw)
        {
            var json = JsonSerializer.Serialize(userPw);
            var data = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await _httpService.GetClient().PostAsync("registerUser", data);

            if (response.IsSuccessStatusCode)
            {
                return((User)JsonSerializer.Deserialize(response.Content.ReadAsStringAsync().Result, typeof(User)));
            }
            throw response.StatusCode switch
                  {
                      HttpStatusCode.InternalServerError => new Exception("Internal Server Error"),
                      _ => new Exception("Username taken")
                  };
        }
        public void RegisterUser_Valid2()
        {
            UserPw temp = new UserPw {
                Name = "User 2", Password = "******"
            };
            var json = JsonSerializer.Serialize(temp);
            var data = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = Client.PostAsync("registerUser", data).Result;

            Console.WriteLine("StatusCode: " + response.StatusCode + "\n");
            Assert.IsTrue(response.IsSuccessStatusCode);
            if (response.IsSuccessStatusCode)
            {
                User res = (User)JsonSerializer.Deserialize(response.Content.ReadAsStringAsync().Result, typeof(User));
                Console.WriteLine(res);
                Assert.IsTrue(res.Name.Equals(temp.Name));
            }
        }
        public void DeleteUser_Valid()
        {
            UserPw temp = new UserPw {
                Name = "For Delete 1", Password = "******"
            };
            var json = JsonSerializer.Serialize(temp);
            var data = new StringContent(json, Encoding.UTF8, "application/json");

            Client.PostAsync("registerUser", data);
            Thread.Sleep(200);

            String temp1 = "For Delete 1";
            HttpResponseMessage response = Client.DeleteAsync("deleteUser/" + temp1).Result;

            Console.WriteLine("StatusCode: " + response.StatusCode + "\n");
            Assert.IsTrue(response.IsSuccessStatusCode);
            Thread.Sleep(200);

            response = Client.GetAsync("getUser/" + temp1).Result;
            Assert.IsFalse(response.IsSuccessStatusCode);
        }
 public async Task UpdatePw(UserPw userPw)
 {
     var json = JsonSerializer.Serialize(userPw);
     var data = new StringContent(json, Encoding.UTF8, "application/json");
     await _httpService.GetClient().PatchAsync("patchUserPassword", data);
 }