public async Task CreateMealAsync_WithValidModel_ShouldAddMealInDatabase() { MealCreateBindingModel model = new MealCreateBindingModel(); await service.CreateMealAsync(model, MockUserManager.testUsername); Assert.AreEqual(1, dbContext.Meals.Count()); }
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(); }