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>()); }
private void RunInPeriod(Settings settings) { trial.IsTrial((isTrial) => { if (isTrial) ConfirmAndShow(); settings.TrialCounter = 0; }); }
public void TestInitialize() { factories = Substitute.For<Factories>(); cloudProviderFactory = Substitute.For<CloudProviderFactory>(); cloudProvider = Substitute.For<CloudProvider>(); cloudProviderFactory.Create().Returns(cloudProvider); settings = new Settings(); factories.Settings.Returns(settings); vibration = Substitute.For<Vibration>(); cloud = Substitute.For<Cloud>(); messageDialog = Substitute.For<MessageDialog>(); cloudMessages = new Fixture().Create<CloudMessages>(); workerFactory = new BackgroundWorkerSyncFactory(); sut = new ExportAndImportViewModel(factories, cloudProviderFactory, vibration, cloud, messageDialog, cloudMessages, workerFactory); cloudProvider.GetAcquiredToken().Returns(new CloudToken { Secret = "foo", Token = "bar" }); cloudProvider.GetTokenAcquiringUrl(ExportAndImportViewModel.TOKEN_ACQUIRING_CALLBACK_URL).Returns("go"); cloud.ListImports().Returns(new List<string>()); navigatedTo = string.Empty; sut.NavigateInBrowser += (_, url) => { navigatedTo = url; }; }