public void TestInitialize()
 {
     var fixture = new Fixture();
     factories = Substitute.For<Factories>();
     navigator = Substitute.For<Navigator>();
     stateProvider = Substitute.For<StateProvider>();
     facade = Substitute.For<ReplacementBuilderAndSugarEstimatorFacade>();
     clipboard = Substitute.For<Clipboard>();
     messageDialog = Substitute.For<MessageDialog>();
     navigation = new InsulinEditingViewModel.Navigation();
     CreateSut();
     insulin = fixture.Create<Insulin>();
     insulin.InitializeCircumstances(new List<Guid>());
     insulin.SetOwner(factories);
     sugar = new Sugar();
     sugar.SetOwner(factories);
     factories.InsulinCircumstances.Returns(fixture.CreateMany<InsulinCircumstance>().ToList());
     factories.CreateSugar().Returns(sugar);
     settings = new Settings { MaxBolus = 5 };
     factories.Settings.Returns(settings);
     meal = fixture.Create<Meal>();
     factories.Finder.FindMealByInsulin(insulin).Returns(meal);
     factories.Finder.FindInsulinById(insulin.Id).Returns(insulin);
     var replacementAndEstimatedSugars = new ReplacementAndEstimatedSugars();
     replacementAndEstimatedSugars.EstimatedSugars = new List<Sugar>();
     replacementAndEstimatedSugars.Replacement
         = new Replacement { InsulinTotal = new Insulin(), Items = new List<ReplacementItem>() };
     facade.GetReplacementAndEstimatedSugars(Arg.Any<Meal>(), Arg.Any<Insulin>(), Arg.Any<Sugar>())
             .Returns(replacementAndEstimatedSugars);
     factories.MealNames.Returns(new List<MealName>());
     stateProvider.State.Returns(new Dictionary<string, object>());
 }
示例#2
0
 public void BloodSugarInMgdL(float from, SugarUnit unit, float expectedTo)
 {
     var factories = new FactoriesImpl();
     factories.StorageCreator = new StorageCreatorStub();
     factories.Settings.SugarUnit = unit;
     var sut = new Sugar { BloodSugar = from };
     sut.SetOwner(factories);
     Assert.AreEqual(expectedTo, sut.BloodSugarInMgdL);
 }
 private void SetupSugars()
 {
     var sugar = new Sugar();
     sugar.SetOwner(factories);
     sugar.Id = Guid.NewGuid();
     factories.Sugars.Returns(new List<Sugar> { sugar });
     factories.CreateSugar().Returns(_ => { factories.Sugars.Add(sugar); return sugar; });
 }