public void FaseCyclusViewModel_NameChanged_NameChangedMessageSent() { var messengermock = FakesCreator.CreateMessenger(); Messenger.OverrideDefault(messengermock); var model = new ControllerModel(); TLCGenControllerDataProvider.OverrideDefault(FakesCreator.CreateControllerDataProvider(model)); TLCGenModelManager.OverrideDefault(new TLCGenModelManager { Controller = model }); model.Fasen.Add(new FaseCyclusModel { Naam = "01" }); model.Fasen.Add(new FaseCyclusModel { Naam = "02" }); model.Fasen.Add(new FaseCyclusModel { Naam = "03" }); model.Fasen.Add(new FaseCyclusModel { Naam = "04" }); model.Fasen.Add(new FaseCyclusModel { Naam = "05" }); var vm = new FaseCyclusViewModel(model.Fasen[2]) { Naam = "07" }; messengermock.Received().Send(Arg.Is <NameChangingMessage>(x => x.OldName == "03" && x.NewName == "07")); }
public void FaseCyclusViewModel_NameChanged_DetectorNamesAlsoChanged() { var model = new ControllerModel(); Messenger.OverrideDefault(new Messenger()); SettingsProvider.OverrideDefault(FakesCreator.CreateSettingsProvider()); DefaultsProvider.OverrideDefault(FakesCreator.CreateDefaultsProvider()); TLCGenControllerDataProvider.OverrideDefault(FakesCreator.CreateControllerDataProvider(model)); TLCGenModelManager.OverrideDefault(new TLCGenModelManager { Controller = model }); model.Fasen.Add(new FaseCyclusModel { Naam = "01", Detectoren = new List <DetectorModel> { new DetectorModel { Naam = "01_1", VissimNaam = "011" }, new DetectorModel { Naam = "01_2", VissimNaam = "012" } } }); var vm = new FaseCyclusViewModel(model.Fasen[0]) { Naam = "05" }; Assert.AreEqual("05_1", vm.FaseCyclus.Detectoren[0].Naam); Assert.AreEqual("051", vm.FaseCyclus.Detectoren[0].VissimNaam); Assert.AreEqual("05_2", vm.FaseCyclus.Detectoren[1].Naam); Assert.AreEqual("052", vm.FaseCyclus.Detectoren[1].VissimNaam); }
public void FasenDetailsTabSelected_ControllerHas5Fasen_TabAlsoExposes5Fasen() { var model = new ControllerModel(); model.Fasen.Add(new FaseCyclusModel() { Naam = "01" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "02" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "03" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "04" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "05" }); var vm = new FasenDetailsTabViewModel(); vm.Controller = model; TLCGenControllerDataProvider.OverrideDefault(FakesCreator.CreateControllerDataProvider(model)); vm.OnSelected(); Assert.AreEqual(5, vm.Fasen.Count); }
public void FaseAddedToModel_TwoGroentijdenSetsInModel_FaseAddedToBothSets() { var model = new ControllerModel(); Messenger.OverrideDefault(new Messenger()); SettingsProvider.OverrideDefault(FakesCreator.CreateSettingsProvider()); DefaultsProvider.OverrideDefault(FakesCreator.CreateDefaultsProvider()); TLCGenControllerDataProvider.OverrideDefault(FakesCreator.CreateControllerDataProvider(model)); TLCGenModelManager.OverrideDefault(new TLCGenModelManager { Controller = model }); model.Fasen.Add(new FaseCyclusModel { Naam = "03" }); model.Fasen.Add(new FaseCyclusModel { Naam = "04" }); model.Fasen.Add(new FaseCyclusModel { Naam = "05" }); model.Fasen.Add(new FaseCyclusModel { Naam = "06" }); model.Fasen.Add(new FaseCyclusModel { Naam = "08" }); var vm = new FasenGroentijdenSetsTabViewModel { Controller = model }; var vmfasen = new FasenLijstTabViewModel { Controller = model }; vm.AddGroentijdenSetCommand.Execute(null); vm.AddGroentijdenSetCommand.Execute(null); vmfasen.AddFaseCommand.Execute(null); vm.OnFasenChanged(new FasenChangedMessage(new List <FaseCyclusModel> { model.Fasen[5] }, null)); Assert.AreEqual(6, model.GroentijdenSets[0].Groentijden.Count); Assert.AreEqual("03", model.GroentijdenSets[0].Groentijden[0].FaseCyclus); Assert.AreEqual("04", model.GroentijdenSets[0].Groentijden[1].FaseCyclus); Assert.AreEqual("05", model.GroentijdenSets[0].Groentijden[2].FaseCyclus); Assert.AreEqual("06", model.GroentijdenSets[0].Groentijden[3].FaseCyclus); Assert.AreEqual("08", model.GroentijdenSets[0].Groentijden[4].FaseCyclus); Assert.AreEqual("09", model.GroentijdenSets[0].Groentijden[5].FaseCyclus); Assert.AreEqual(6, model.GroentijdenSets[1].Groentijden.Count); Assert.AreEqual("03", model.GroentijdenSets[1].Groentijden[0].FaseCyclus); Assert.AreEqual("04", model.GroentijdenSets[1].Groentijden[1].FaseCyclus); Assert.AreEqual("05", model.GroentijdenSets[1].Groentijden[2].FaseCyclus); Assert.AreEqual("06", model.GroentijdenSets[1].Groentijden[3].FaseCyclus); Assert.AreEqual("08", model.GroentijdenSets[1].Groentijden[4].FaseCyclus); Assert.AreEqual("09", model.GroentijdenSets[1].Groentijden[5].FaseCyclus); }
public void FaseRemovedFromModel_TwoGroentijdenSetsInModel_FaseRemovedFromBothSets() { var model = new ControllerModel(); Messenger.OverrideDefault(new Messenger()); SettingsProvider.OverrideDefault(FakesCreator.CreateSettingsProvider()); DefaultsProvider.OverrideDefault(FakesCreator.CreateDefaultsProvider()); TLCGenModelManager.OverrideDefault(new TLCGenModelManager { Controller = model }); TLCGenControllerDataProvider.OverrideDefault(FakesCreator.CreateControllerDataProvider(model)); model.Fasen.Add(new FaseCyclusModel { Naam = "03" }); model.Fasen.Add(new FaseCyclusModel { Naam = "04" }); model.Fasen.Add(new FaseCyclusModel { Naam = "05" }); model.Fasen.Add(new FaseCyclusModel { Naam = "06" }); model.Fasen.Add(new FaseCyclusModel { Naam = "08" }); var vm = new FasenGroentijdenSetsTabViewModel { Controller = model }; var vmfasen = new FasenLijstTabViewModel { Controller = model }; vm.AddGroentijdenSetCommand.Execute(null); vm.AddGroentijdenSetCommand.Execute(null); vmfasen.SelectedFaseCyclus = vmfasen.Fasen[2]; vmfasen.RemoveFaseCommand.Execute(null); Assert.AreEqual(4, model.GroentijdenSets[0].Groentijden.Count); Assert.AreEqual("03", model.GroentijdenSets[0].Groentijden[0].FaseCyclus); Assert.AreEqual("04", model.GroentijdenSets[0].Groentijden[1].FaseCyclus); Assert.AreEqual("06", model.GroentijdenSets[0].Groentijden[2].FaseCyclus); Assert.AreEqual("08", model.GroentijdenSets[0].Groentijden[3].FaseCyclus); Assert.AreEqual(4, model.GroentijdenSets[1].Groentijden.Count); Assert.AreEqual("03", model.GroentijdenSets[1].Groentijden[0].FaseCyclus); Assert.AreEqual("04", model.GroentijdenSets[1].Groentijden[1].FaseCyclus); Assert.AreEqual("06", model.GroentijdenSets[1].Groentijden[2].FaseCyclus); Assert.AreEqual("08", model.GroentijdenSets[1].Groentijden[3].FaseCyclus); }
public void OnNameChanged_FaseRenamedLowerThanOthers_FaseNamedCorrectlyForDisplay() { var model = new ControllerModel(); Messenger.OverrideDefault(new Messenger()); SettingsProvider.OverrideDefault(FakesCreator.CreateSettingsProvider()); DefaultsProvider.OverrideDefault(FakesCreator.CreateDefaultsProvider()); TLCGenControllerDataProvider.OverrideDefault(FakesCreator.CreateControllerDataProvider(model)); TLCGenModelManager.OverrideDefault(new TLCGenModelManager { Controller = model }); model.Fasen.Add(new FaseCyclusModel() { Naam = "05" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "06" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "07" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "08" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "09" }); var vm = new FasenGroentijdenSetsTabViewModel(); vm.Controller = model; var vmfasen = new FasenLijstTabViewModel(); vmfasen.Controller = model; vm.AddGroentijdenSetCommand.Execute(null); var oldname = vmfasen.Fasen[2].Naam; vmfasen.Fasen[2].Naam = "02"; vm.OnNameChanged(new NameChangedMessage(TLCGenObjectTypeEnum.Fase, oldname, vmfasen.Fasen[2].Naam)); Assert.AreEqual( new string[5] { "02", "05", "06", "08", "09" }, vm.FasenNames.ToArray()); }
public void AddFaseCommand_Executed_AddsFase() { var model = new ControllerModel(); Messenger.OverrideDefault(new Messenger()); DefaultsProvider.OverrideDefault(FakesCreator.CreateDefaultsProvider()); TLCGenModelManager.OverrideDefault(new TLCGenModelManager { Controller = model }); TLCGenControllerDataProvider.OverrideDefault(FakesCreator.CreateControllerDataProvider(model)); var vm = new FasenLijstTabViewModel { Controller = model }; vm.AddFaseCommand.Execute(null); Assert.AreEqual(1, model.Fasen.Count); }
public void FasenTimersTabMultipleSelectionEdit_TGLChangedOnOnePhase_ChangesAllSelected() { var model = new ControllerModel(); Messenger.OverrideDefault(new Messenger()); TemplatesProvider.OverrideDefault(FakesCreator.CreateTemplatesProvider()); model.Fasen.Add(new FaseCyclusModel { Naam = "01", TGL = 30 }); model.Fasen.Add(new FaseCyclusModel { Naam = "02", TGL = 30 }); model.Fasen.Add(new FaseCyclusModel { Naam = "03", TGL = 30 }); model.Fasen.Add(new FaseCyclusModel { Naam = "04", TGL = 30 }); model.Fasen.Add(new FaseCyclusModel { Naam = "05", TGL = 30 }); TLCGenModelManager.OverrideDefault(new TLCGenModelManager { Controller = model }); TLCGenControllerDataProvider.OverrideDefault(FakesCreator.CreateControllerDataProvider(model)); ControllerAccessProvider.OverrideDefault(FakesCreator.CreateControllerAccessProvider(model)); var vm = new FasenLijstTimersTabViewModel { Controller = model }; vm.OnSelected(); vm.SelectedItems = new List <FaseCyclusViewModel> { vm.Fasen[1], vm.Fasen[2], vm.Fasen[3] }; vm.Fasen[3].TGL = 50; Assert.AreEqual(30, vm.Fasen[0].TGL); Assert.AreEqual(50, vm.Fasen[1].TGL); Assert.AreEqual(50, vm.Fasen[2].TGL); Assert.AreEqual(50, vm.Fasen[3].TGL); Assert.AreEqual(30, vm.Fasen[4].TGL); }
public void OnNameChanged_FaseRenamedHigherThanOthers_FaseNamedCorrectlyForDisplay() { var model = new ControllerModel(); Messenger.OverrideDefault(new Messenger()); SettingsProvider.OverrideDefault(FakesCreator.CreateSettingsProvider()); DefaultsProvider.OverrideDefault(FakesCreator.CreateDefaultsProvider()); TLCGenControllerDataProvider.OverrideDefault(FakesCreator.CreateControllerDataProvider(model)); TLCGenModelManager.OverrideDefault(new TLCGenModelManager { Controller = model }); model.Fasen.Add(new FaseCyclusModel { Naam = "01" }); model.Fasen.Add(new FaseCyclusModel { Naam = "02" }); model.Fasen.Add(new FaseCyclusModel { Naam = "03" }); model.Fasen.Add(new FaseCyclusModel { Naam = "04" }); model.Fasen.Add(new FaseCyclusModel { Naam = "05" }); var vm = new FasenGroentijdenSetsTabViewModel { Controller = model }; var vmfasen = new FasenLijstTabViewModel { Controller = model }; vm.AddGroentijdenSetCommand.Execute(null); vmfasen.Fasen[2].Naam = "07"; Assert.AreEqual( new string[5] { "01", "02", "04", "05", "07" }, vm.FasenNames.ToArray()); }
public void RenameFase_LowerThanOthers_SortsCorrectlyAfterTabChange() { var model = new ControllerModel(); Messenger.OverrideDefault(new Messenger()); DefaultsProvider.OverrideDefault(FakesCreator.CreateDefaultsProvider()); TLCGenModelManager.OverrideDefault(new TLCGenModelManager { Controller = model }); TLCGenControllerDataProvider.OverrideDefault(FakesCreator.CreateControllerDataProvider(model)); model.Fasen.Add(new FaseCyclusModel() { Naam = "03" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "04" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "07" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "08" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "09" }); var vm = new FasenLijstTabViewModel(); vm.Controller = model; vm.Fasen[4].Naam = "05"; vm.OnDeselectedPreview(); Assert.AreEqual("05", vm.Fasen[2].Naam); Assert.AreEqual("08", vm.Fasen[4].Naam); }
public void AddFaseCommand_Executed5Times_5thFaseCorrectlyNamed() { var model = new ControllerModel(); Messenger.OverrideDefault(new Messenger()); DefaultsProvider.OverrideDefault(FakesCreator.CreateDefaultsProvider()); TLCGenModelManager.OverrideDefault(new TLCGenModelManager { Controller = model }); TLCGenControllerDataProvider.OverrideDefault(FakesCreator.CreateControllerDataProvider(model)); var vm = new FasenLijstTabViewModel { Controller = model }; vm.AddFaseCommand.Execute(null); vm.AddFaseCommand.Execute(null); vm.AddFaseCommand.Execute(null); vm.AddFaseCommand.Execute(null); vm.AddFaseCommand.Execute(null); Assert.AreEqual("05", model.Fasen[4].Naam); }
public void FasenDetailsTabSelectedFase_TabDeselectedAndSelected_SelectedFaseEqual() { var model = new ControllerModel(); model.Fasen.Add(new FaseCyclusModel() { Naam = "01" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "02" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "03" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "04" }); model.Fasen.Add(new FaseCyclusModel() { Naam = "05" }); var vm = new FasenDetailsTabViewModel(); vm.Controller = model; TLCGenControllerDataProvider.OverrideDefault(FakesCreator.CreateControllerDataProvider(model)); vm.OnSelected(); vm.SelectedFaseCyclus = vm.Fasen[3]; vm.OnDeselected(); vm.OnSelected(); Assert.True(object.ReferenceEquals(vm.SelectedFaseCyclus, vm.Fasen[3])); }