Пример #1
0
        public void AddAndRemoveFasen()
        {
            // Setup variables
            SettingsProvider.Instance.Settings = new TLCGen.Models.Settings.TLCGenSettingsModel();
            DataProvider.Instance.SetController();
            var tab = new FasenTabViewModel(DataProvider.Instance.Controller);

            // Add phase possible, remove phase not
            Assert.IsTrue(tab.AddFaseCommand.CanExecute(null));
            Assert.IsFalse(tab.RemoveFaseCommand.CanExecute(null));
            // No phases yet
            Assert.AreEqual(tab.Fasen.Count, 0);

            // Add phase, assert command can execute is the same, phases count increased
            AddFaseAndAssert(tab, 1);
            // Add phase, assert command can execute is the same, phases count increased
            AddFaseAndAssert(tab, 2);

            // Remove phase
            RemoveFaseAndAssert(tab, 1);
            // Remove phase: all are gone
            RemoveFaseAndAssert(tab, 0);

            Thread.Sleep(250);
        }
Пример #2
0
 private void AddFaseAndAssert(FasenTabViewModel tab, int count)
 {
     tab.AddFaseCommand.Execute(null);
     Assert.IsTrue(tab.AddFaseCommand.CanExecute(null));
     Assert.IsFalse(tab.RemoveFaseCommand.CanExecute(null));
     Assert.AreEqual(tab.Fasen.Count, count);
 }
Пример #3
0
 private void AssertGroentijd(FasenTabViewModel tab, int maxindex, int phaseindex, int val)
 {
     Assert.IsTrue(tab.GroentijdenLijstVM.GroentijdenSets.Count > 0);
     Assert.IsTrue(tab.GroentijdenLijstVM.GroentijdenSets[0].GroentijdenSetList.Count == maxindex);
     Assert.IsTrue(tab.GroentijdenLijstVM.GroentijdenSets[0].GroentijdenSet.Groentijden.Count == maxindex);
     Assert.AreEqual(val, tab.GroentijdenLijstVM.GroentijdenMatrix[0, phaseindex].Waarde);
     Assert.AreEqual(val, tab.GroentijdenLijstVM.GroentijdenSets[0].GroentijdenSetList[phaseindex].Waarde);
     Assert.AreEqual(val, tab.GroentijdenLijstVM.GroentijdenSets[0].GroentijdenSet.Groentijden[phaseindex].Waarde);
 }
Пример #4
0
        public void AddRemoveGreenTimeSet()
        {
            // Setup variables
            SettingsProvider.Instance.Settings = new TLCGen.Models.Settings.TLCGenSettingsModel();
            DataProvider.Instance.SetController();
            var tab = new FasenTabViewModel(DataProvider.Instance.Controller);

            Assert.AreEqual(tab.Fasen.Count, 0);
            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets.Count, 0);

            // Add phases
            tab.AddFaseCommand.Execute(null);
            tab.AddFaseCommand.Execute(null);
            Assert.AreEqual(tab.Fasen.Count, 2);

            // Assert on greentimes
            Assert.IsTrue(tab.GroentijdenLijstVM.AddGroentijdenSetCommand.CanExecute(null));
            Assert.IsFalse(tab.GroentijdenLijstVM.RemoveGroentijdenSetCommand.CanExecute(null));
            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets.Count, 0);

            // Add greentime set
            tab.GroentijdenLijstVM.AddGroentijdenSetCommand.Execute(null);
            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets.Count, 1);
            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets[0].GroentijdenSet.Groentijden.Count, 2);

            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets[0].GroentijdenSet.Groentijden[0].FaseCyclus, tab.Fasen[0].Define);
            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets[0].GroentijdenSet.Groentijden[0].Waarde,
                            tab.GroentijdenLijstVM.GroentijdenMatrix[0, 0].Waarde);
            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets[0].GroentijdenSet.Groentijden[1].Waarde,
                            tab.GroentijdenLijstVM.GroentijdenMatrix[0, 1].Waarde);

            tab.GroentijdenLijstVM.GroentijdenMatrix[0, 1].Waarde = 123;
            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets[0].GroentijdenSet.Groentijden[1].Waarde,
                            123);

            // Remove phase
            tab.SelectedFaseCyclus = tab.Fasen[0];
            tab.RemoveFaseCommand.Execute(null);
            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets[0].GroentijdenSet.Groentijden.Count, 1);

            // Remove phase: all are gone
            tab.SelectedFaseCyclus = tab.Fasen[0];
            tab.RemoveFaseCommand.Execute(null);
            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets[0].GroentijdenSet.Groentijden.Count, 0);

            // Remove greentime set
            Assert.IsFalse(tab.GroentijdenLijstVM.RemoveGroentijdenSetCommand.CanExecute(null));
            tab.GroentijdenLijstVM.SelectedSet = tab.GroentijdenLijstVM.GroentijdenSets[0];
            Assert.IsTrue(tab.GroentijdenLijstVM.RemoveGroentijdenSetCommand.CanExecute(null));
            tab.GroentijdenLijstVM.RemoveGroentijdenSetCommand.Execute(null);
            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets.Count, 0);
            Assert.IsTrue(tab.GroentijdenLijstVM.AddGroentijdenSetCommand.CanExecute(null));
            Assert.IsFalse(tab.GroentijdenLijstVM.RemoveGroentijdenSetCommand.CanExecute(null));
        }
Пример #5
0
        public void SortFasen()
        {
            // Setup variables
            SettingsProvider.Instance.Settings = new TLCGen.Models.Settings.TLCGenSettingsModel();
            DataProvider.Instance.SetController();
            var tab = new FasenTabViewModel(DataProvider.Instance.Controller);

            // Add phase possible, remove phase not
            Assert.IsTrue(tab.AddFaseCommand.CanExecute(null));
            Assert.IsFalse(tab.RemoveFaseCommand.CanExecute(null));
            // No phases yet
            Assert.AreEqual(tab.Fasen.Count, 0);

            // Add phase, assert command can execute is the same, phases count increased
            AddFaseAndAssert(tab, 1);
            // Add phase, assert command can execute is the same, phases count increased
            AddFaseAndAssert(tab, 2);
            // Add phase, assert command can execute is the same, phases count increased
            AddFaseAndAssert(tab, 3);

            // Add greentime set
            tab.GroentijdenLijstVM.AddGroentijdenSetCommand.Execute(null);
            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets.Count, 1);
            // Change value of second phase
            tab.GroentijdenLijstVM.GroentijdenMatrix[0, 0].Waarde = 111; // 1
            tab.GroentijdenLijstVM.GroentijdenMatrix[0, 1].Waarde = 222; // 2
            tab.GroentijdenLijstVM.GroentijdenMatrix[0, 2].Waarde = 333; // 3

            // Rename second phase
            tab.Fasen[1].Naam = "04"; // 02 --> 04 (2)
            // Change tab index to cause sorting
            tab.SelectedTabIndex = 1;
            tab.SelectedTabIndex = 0;

            // Assert the last two phases changed places
            Assert.AreEqual("01", tab.Fasen[0].Naam);                    // 1
            Assert.AreEqual("03", tab.Fasen[1].Naam);                    // 3
            Assert.AreEqual("04", tab.Fasen[2].Naam);                    // 2
            // Assert the greentime for phase 04 moved to the bottom
            Assert.AreEqual("01", tab.GroentijdenLijstVM.FasenNames[0]); // 1
            Assert.AreEqual("03", tab.GroentijdenLijstVM.FasenNames[1]); // 3
            Assert.AreEqual("04", tab.GroentijdenLijstVM.FasenNames[2]); // 2
            AssertGroentijd(tab, 3, 0, 111);
            AssertGroentijd(tab, 3, 1, 333);
            AssertGroentijd(tab, 3, 2, 222);

            // Rename second phase
            tab.Fasen[0].Naam = "15"; // 01 --> 15 (1)
            // Change tab index to cause sorting
            tab.SelectedTabIndex = 1;
            tab.SelectedTabIndex = 0;
            // Assert the last two phases changed places
            Assert.AreEqual("03", tab.Fasen[0].Naam);                    // 2
            Assert.AreEqual("04", tab.Fasen[1].Naam);                    // 3
            Assert.AreEqual("15", tab.Fasen[2].Naam);                    // 1
            // Assert the greentime for phase 04 moved to the bottom
            Assert.AreEqual("03", tab.GroentijdenLijstVM.FasenNames[0]); // 2
            Assert.AreEqual("04", tab.GroentijdenLijstVM.FasenNames[1]); // 3
            Assert.AreEqual("15", tab.GroentijdenLijstVM.FasenNames[2]); // 1
            AssertGroentijd(tab, 3, 0, 333);
            AssertGroentijd(tab, 3, 1, 222);
            AssertGroentijd(tab, 3, 2, 111);

            // Rename third phase
            tab.Fasen[1].Naam = "01"; // 04 --> 01 (2)
            // Change tab index to cause sorting
            tab.SelectedTabIndex = 1;
            tab.SelectedTabIndex = 0;
            // Assert the last two phases changed places
            Assert.AreEqual("01", tab.Fasen[0].Naam);                    // 2
            Assert.AreEqual("03", tab.Fasen[1].Naam);                    // 3
            Assert.AreEqual("15", tab.Fasen[2].Naam);                    // 1
            // Assert the greentime for phase 04 moved to the bottom
            Assert.AreEqual("01", tab.GroentijdenLijstVM.FasenNames[0]); // 2
            Assert.AreEqual("03", tab.GroentijdenLijstVM.FasenNames[1]); // 3
            Assert.AreEqual("15", tab.GroentijdenLijstVM.FasenNames[2]); // 1
            AssertGroentijd(tab, 3, 0, 222);
            AssertGroentijd(tab, 3, 1, 333);
            AssertGroentijd(tab, 3, 2, 111);

            // clean up: remove phases, sets
            RemoveFaseAndAssert(tab, 2);
            RemoveFaseAndAssert(tab, 1);
            RemoveFaseAndAssert(tab, 0);
            tab.GroentijdenLijstVM.SelectedSet = tab.GroentijdenLijstVM.GroentijdenSets[0];
            tab.GroentijdenLijstVM.RemoveGroentijdenSetCommand.Execute(null);
            Assert.AreEqual(tab.GroentijdenLijstVM.GroentijdenSets.Count, 0);
        }