예제 #1
0
        public async Task GetSingleDailyMeal_ReturnsSuccessStatusCode()
        {
            var dmToBeAssessed = DatabaseToTest.GetDailyMealsToTest().First();

            var response = await _httpClient.GetAsync($"{uri}{dmToBeAssessed.Id}");

            response.EnsureSuccessStatusCode();
        }
예제 #2
0
        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);
        }
예제 #3
0
        //[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);
        }
예제 #4
0
        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);
        }