// ReSharper disable once InconsistentNaming public async void Can_POST_a_new_AccountType() { using (var client = new HttpClient()) { // Arrange var newAccountType = new AccountType { KeyId = Guid.NewGuid(), AccountTypeDesc = "ATN" + DateTime.Now.Hour + DateTime.Now.Minute.ToString(CultureInfo.InvariantCulture) }; // Act var response = await client.PostAsJsonAsync(UrlBase + "/AccountType", newAccountType); // Assert Assert.IsTrue(response.StatusCode == HttpStatusCode.Created); } }
// ReSharper disable once InconsistentNaming public async void Can_PUT_Update_an_AccountType() { using (var client = new HttpClient()) { // Arrange var updatedAccountType = new AccountType { KeyId = new Guid("91d865a6-5446-45b7-bedc-a3c300e8f0f6"), AccountTypeDesc = "ATU" + DateTime.Now.Hour + DateTime.Now.Minute.ToString(CultureInfo.InvariantCulture) }; // Act // Error: "Method not allowed"; statuscode = 405 [Sol: Check routing attribute on action !] var response = await client.PutAsJsonAsync(UrlBase + "/AccountType", updatedAccountType); // Assert Assert.IsTrue(response.StatusCode == HttpStatusCode.NoContent); } }
// ReSharper disable once InconsistentNaming // Admin only public async void Can_DELETE_an_AccountType() { using (var client = new HttpClient()) { // Arrange var acctTypeToDelete = new AccountType { KeyId = Guid.NewGuid(), AccountTypeDesc = "ATD" + DateTime.Now.Hour + DateTime.Now.Minute.ToString(CultureInfo.InvariantCulture) }; await client.PostAsJsonAsync(UrlBase + "/AccountType", acctTypeToDelete); // Act var reqUrl = UrlBase + "/AccountType/" + acctTypeToDelete.AccountTypeDesc.Trim(); var response = await client.DeleteAsync(reqUrl); // Assert Assert.IsTrue(response.StatusCode == HttpStatusCode.NoContent); // 204 status code } }
// ReSharper disable once InconsistentNaming public async void Can_not_POST_a_duplicate_AccountType() { using (var client = new HttpClient()) { // Arrange var newAccountType = new AccountType { KeyId = new Guid("18d97297-bfe8-4746-9e2a-be9bc2c0e9e4"), AccountTypeDesc = "ROTH-IRA" }; // Act var response = await client.PostAsJsonAsync(UrlBase + "/AccountType", newAccountType); // Assert Assert.IsTrue(response.StatusCode == HttpStatusCode.Conflict); } }