public void HasName()
 {
     Assert.IsFalse(sut.HasName);
     sut = new MealViewModel(meal, factories);
     sut.Names = new[] { new MealNameViewModel(new MealName { Id = Guid.NewGuid() }, factories) };
     meal.NameId = sut.Names.First().Id;
     Assert.IsTrue(sut.HasName);
 }
 public void IsOlder()
 {
     var factories = Substitute.For<Factories>();
     var meal = new Meal();
     var sut = new MealViewModel(meal, factories);
     Assert.IsFalse(sut.IsOlder);
     sut.Date = DateViewModel.CreateNormalDate(DateTime.Now);
     Assert.IsFalse(sut.IsOlder);
     sut.Date = DateViewModel.CreateGroupOfOlder();
     Assert.IsTrue(sut.IsOlder);
 }
 public void TestInitialize()
 {
     factories = Substitute.For<Factories>();
     meal = new Meal();
     sut = new MealViewModel(meal, factories);
     meal.SetOwner(factories);
     meal.InitializeItems(new List<MealItem>());
     factories.CreateMealItem().Returns(_ =>
     {
         var mealItem = new MealItem();
         mealItem.SetOwner(factories);
         return mealItem;
     });
     var fixture = new Fixture();
     factories.Products.Returns(fixture.CreateMany<Product>(10).ToList());
     factories.Finder.Returns(new FinderImpl(factories));
 }
Пример #4
0
 public PatternViewModel(Pattern pattern, Factories factories,
     IList<InsulinCircumstanceViewModel> allCircumstances, bool hasAlternatives,
     IEnumerable<MealNameViewModel> names, MealNameViewModel defaultName, Navigator navigator, Action save,
     Action showAlternatives)
 {
     Pattern = pattern;
     Match = new MealItemViewModel(pattern.Match, factories);
     From = new MealViewModel(pattern.From, factories);
     From.Names = names;
     From.DefaultName = defaultName;
     Insulin = new InsulinViewModel(pattern.Insulin, factories, allCircumstances: allCircumstances);
     Before = new SugarViewModel(pattern.Before, factories);
     After = pattern.After
         .Select(sugar => new SugarViewModel(sugar, factories))
         .ToList();
     For = new MealItemViewModel(pattern.For, factories);
     HasAlternatives = hasAlternatives;
     this.navigator = navigator;
     this.save = save;
     this.showAlternatives = showAlternatives;
 }
 public void TestInitialize()
 {
     insulin = new InsulinViewModel(new Insulin(), Substitute.For<Factories>(), null);
     sugar = new SugarViewModel(new Sugar(), Substitute.For<Factories>());
     meal = new MealViewModel(new Meal(), Substitute.For<Factories>());
 }
 public void ChooseWhenMeal()
 {
     var navigator = new Mock<Navigator>();
     sut.Navigator = navigator.Object;
     var meal = new MealViewModel(new Meal { Id = Guid.NewGuid() }, factories);
     sut.Choose(meal);
     navigator.Verify(Navigator => Navigator.GoToMealEditing(meal.Id));
 }
Пример #7
0
 private void LoadUnsortedMeals()
 {
     var models = factories.Meals;
     unsortedMeals = new List<MealViewModel>();
     foreach (var model in models)
     {
         var viewModel = new MealViewModel(model, factories)
         {
             Names = names,
             DefaultName = defaultName
         };
         unsortedMeals.Add(viewModel);
     }
 }
Пример #8
0
 public MealScoreSelector(MealViewModel meal)
     : base(meal.factories)
 {
     this.meal = meal;
 }