示例#1
0
        public async Task CreateMealAsync_WithValidModel_ShouldAddMealInDatabase()
        {
            MealCreateBindingModel model = new MealCreateBindingModel();

            await service.CreateMealAsync(model, MockUserManager.testUsername);

            Assert.AreEqual(1, dbContext.Meals.Count());
        }
示例#2
0
        public async Task CreateMealAsync(MealCreateBindingModel model, string username)
        {
            var user = await this.GetUserByNamedAsync(username);

            CoreValidator.ThrowIfNull(model);

            user.Meals.Add(this.Mapper.Map <Meal>(model));
            await this.DbContext.SaveChangesAsync();
        }