public async Task TestPutInvalidBrandStockItemAsync() { // Arrange var request = new { Url = "/api/StockItem/1", Body = new { Name = "Холодильник Юпитер-2", Brand = "xEnwh6aPtenVHKjENaUxojbqMVtecMKZDZ7lo6XsEt3hMX5kuk63Cj4pq32s4xGN530su7sXitfn6FGyngMqNvVX47Mvf2oxQhXMmd9b5vBRDGdZ5GffPAJojjmsErsqeDbrRmTm0KulZNJhiJRvLRUrFnWbSIlc5S7mLvVhyEmVmTVEcwXjifZQVERDyoFjWhNgNpSON", Price = 2000 } }; // Act var putResponse = await _client.PutAsync(request.Url, ContentHelper.GetStringContent(request.Body)); // Assert Assert.True(putResponse.StatusCode == HttpStatusCode.BadRequest); }
public async Task TestPutStockItemAsync() { // Arrange var request = new { Url = "/api/StockItem/1", Body = new { Name = "Холодильник Юпитер-2", Brand = "Космос", Price = 2000 } }; // Act var putResponse = await _client.PutAsync(request.Url, ContentHelper.GetStringContent(request.Body)); // Assert putResponse.EnsureSuccessStatusCode(); }
public async Task TestPutUnExistedStockItemAsync() { // Arrange var request = new { Url = $"/api/StockItem/{int.MaxValue}", Body = new { Name = "Холодильник Юпитер-2", Brand = "Космос", Price = 2000 } }; // Act var putResponse = await _client.PutAsync(request.Url, ContentHelper.GetStringContent(request.Body)); // Act var errorDetails = JsonConvert.DeserializeObject <ErrorDetails>(await putResponse.Content.ReadAsStringAsync()); // Assert Assert.True(putResponse.StatusCode == HttpStatusCode.InternalServerError && errorDetails != null); }