public async Task GetSingleDailyMeal_ReturnsSuccessStatusCode() { var dmToBeAssessed = DatabaseToTest.GetDailyMealsToTest().First(); var response = await _httpClient.GetAsync($"{uri}{dmToBeAssessed.Id}"); response.EnsureSuccessStatusCode(); }
public async Task AddDailyMeal_IfDailyMealInDatabase_ReturnsConflict() { var dailyMealToPass = DatabaseToTest.GetDailyMealToAddToTest().First(); var content = JsonContent.Create(dailyMealToPass); var response = await _httpClient.PostAsync("", content); Assert.Equal(HttpStatusCode.Conflict, response.StatusCode); }
//[Fact] public async Task GetSingleDailyMeal_GetExpectedDailyMeal() { var dmToBeAssessed = DatabaseToTest.GetDailyMealsToTest().First(); var response = await _httpClient.GetFromJsonAsync <ExpectedDailyMealBasicDto>($"{uri}{dmToBeAssessed.Id}"); Assert.NotNull(response); Assert.Equal(dmToBeAssessed.Title, response.Title); Assert.Equal(dmToBeAssessed.Grams, response.Grams); Assert.Equal(dmToBeAssessed.Id, response.Id); }
public async Task GetDailyMeals_AssignedToCreator() { _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("test"); var response = await _httpClient.GetAsync(""); var model = JsonSerializer .Deserialize <List <ExpectedDailyMealBasicDto> >(await response.Content.ReadAsStringAsync()); var expectedNumber = DatabaseToTest .GetDailyMealsToTest().Count(dm => dm.CreatedBy == 1); Assert.Equal(expectedNumber, model.Count); }