public void GivenNewDietDay_WhenCreated_ThenMealsAreCreated() { var dietDay = new DietDay(); Assert.NotNull(dietDay.Meals[DietScheduledMealType.Breakfast]); Assert.NotNull(dietDay.Meals[DietScheduledMealType.MidMorning]); Assert.NotNull(dietDay.Meals[DietScheduledMealType.Lunch]); Assert.NotNull(dietDay.Meals[DietScheduledMealType.AfternoonSnack]); Assert.NotNull(dietDay.Meals[DietScheduledMealType.Dinner]); }
public void SaveYamlTests() { var rawInput = ReadFile("planInput.txt"); var outputFile = "plan.yaml"; var day = new DietDay(); var meal = new DietScheduledMeal(); //meal.FoodList.Add(food); day.Meals.Add(DietScheduledMealType.Breakfast, meal); day.Meals.Add(DietScheduledMealType.MidMorning, meal); day.Meals.Add(DietScheduledMealType.Lunch, meal); day.Meals.Add(DietScheduledMealType.AfternoonSnack, meal); day.Meals.Add(DietScheduledMealType.Dinner, meal); var diet = new Diet(); diet.AddDay(day); }
public void LoadMonths() { var date = DateTime.Now; DietLogMonth = new DietLogMonth { MonthNumber = date.Month, MonthName = Settings.CultureInfo.DateTimeFormat.GetMonthName(date.Month), Year = date.Year }; var DietDays = new List <DietDay>(); var firstDayOfMonth = new DateTime(date.Year, date.Month, 1); var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1); var lastDayLastMonth = firstDayOfMonth.AddDays(-1); var previousCoundown = PreviousNextMonthDays.GetPreviousCountdown(firstDayOfMonth.DayOfWeek); var nextCoundown = PreviousNextMonthDays.GetNextCountdown(lastDayOfMonth.DayOfWeek); // previous month days for (int ii = previousCoundown - 1; ii > -1; ii--) { DietDays.Add(new DietDay { Date = new DateTime(date.Year, date.Month - 1, lastDayLastMonth.Day - ii), DayStatus = DayStatus.DayOfPreviousMonth }); } // this month days var thisMonthDayCount = DateTime.DaysInMonth(date.Year, date.Month); for (int ii = 1; ii < thisMonthDayCount + 1; ii++) { var dietDay = new DietDay { Date = new DateTime(date.Year, date.Month, ii), DayStatus = DayStatus.EmptyToday, IsEnabled = true }; using var db = new AppDbContext(); if (db.DietLogs.Any(x => x.AddedDate.ToShortDateString() == dietDay.Date.ToShortDateString())) { dietDay.DietLogItems = db.DietLogs.Where(x => x.AddedDate.ToShortDateString() == dietDay.Date.ToShortDateString()).Select(x => new DietLogItem { DietLog = x, DietFood = db.DietFoods.FirstOrDefault(c => c.Id == x.DietFoodId) }).ToObservableCollection(); } if (date.Day == ii) { dietDay.DayStatus = dietDay.DietLogItems.Count > 0 ? DayStatus.LoggedToday : DayStatus.EmptyToday; dietDay.IsDefault = true; } else { dietDay.DayStatus = dietDay.DietLogItems.Count > 0 ? DayStatus.LoggedDay : DayStatus.EmptyDay; } DietDays.Add(dietDay); } // next month days var daysBlockCount = previousCoundown + nextCoundown + thisMonthDayCount; if (daysBlockCount < 42) { nextCoundown += 42 - daysBlockCount; } for (int ii = 1; ii < nextCoundown + 1; ii++) { DietDays.Add(new DietDay { Date = new DateTime(date.Year, date.Month + 1, ii), DayStatus = DayStatus.DayOfNextMonth }); } DietLogMonth.DietDays = DietDays.ToObservableCollection(); }