public async Task When_Adding_Existing_Email_User_Expect_Conflict() { // TODO: Instead of using hard-coded email address here, I would use same email from valid create test above AND make sure they run synchronously!! var newUser = new TandemUser() { EmailAddress = "*****@*****.**", FirstName = "Fred", LastName = "Flinstone", PhoneNumber = "654-987-1234" }; var content = new StringContent(newUser.ToString(), null, "application/json"); var response = await _httpClient.PostAsync("api/v1/user/", content); Assert.True(response.StatusCode == HttpStatusCode.Conflict); }
public async Task When_Adding_Valid_User_Expect_Created() { // TODO: Instead of using Guid email address for uniqueness, I would use the same email address but delete it in test cleanup var newUser = new TandemUser() { EmailAddress = new Guid().ToString() + "@.flinstone.com", FirstName = "Fred", LastName = "Flinstone", PhoneNumber = "654-987-1234" }; var content = new StringContent(newUser.ToString(), null, "application/json"); var response = await _httpClient.PostAsync("api/v1/user/", content); Assert.True(response.StatusCode == HttpStatusCode.Created); }
public static async Task TestPostUri(string uri, TandemUser user) { try { var content = new StringContent(user.ToString(), Encoding.UTF8, "application/json"); var response = await _client.PostAsync(uri, content).ConfigureAwait(false); response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync().ConfigureAwait(false); Console.WriteLine(responseBody); } catch (HttpRequestException e) { Console.WriteLine("\nException Caught!"); Console.WriteLine("\nMessage: {0} ", e.Message); } }