Exemplo n.º 1
0
        public void ViewDataTest_GetSetHasFirstChild_and_Child1Changed()
        {
            // Arrange
            cs_timed_silver.Properties.Settings.Default.AutoOpenLastFile = "No";
            var mf = new MainForm();

            mf.OnLoadCreateBasicViewDataWithView = false;
            mf.OnLoadUpdateViewType = false;

            mf.Show();

            Application.DoEvents();
            //var mf = new MainForm();
            //mf.Show();

            var  vd      = new ViewData(mf.MyDataFile);
            var  vd2     = new ViewData(mf.MyDataFile);
            bool correct = false;

            vd.Child1Changed += delegate(object sender, EventArgs e)
            {
                correct = vd.GetFirstChild() == vd2;
            };
            vd.SetFirstChild(vd2);

            //var newView = new ClockListView(mf);

            // Act
            //Application.DoEvents();

            // Assert
            Assert.IsTrue(correct, "GetFirstChild and SetFirstChild do not work well together.");
            Assert.IsTrue(vd.HasFirstChild(), "HasFirstChild should return true.");
            Assert.IsFalse(vd.HasSecondChild(), "HasFirstChild should return false.");
        }
Exemplo n.º 2
0
        public void ViewDataTest_SwitchChildren()
        {
            // Arrange
            cs_timed_silver.Properties.Settings.Default.AutoOpenLastFile = "No";
            var mf = new MainForm();

            mf.OnLoadCreateBasicViewDataWithView = false;
            mf.OnLoadUpdateViewType = false;

            mf.Show();

            Application.DoEvents();

            var  vd      = new ViewData(mf.MyDataFile);
            var  vd2     = new ViewData(mf.MyDataFile);
            bool correct = true;

            vd.ChildrenSwitched += delegate(object sender, EventArgs e)
            {
                correct = false;
            };
            vd.SetSecondChild(vd2);
            vd.SwitchChildren();

            vd.SetSecondChild(vd2);
            vd.SwitchChildren();

            //var newView = new ClockListView(mf);

            // Act
            //Application.DoEvents();

            // Assert
            Assert.AreEqual(vd2, vd.GetFirstChild(), "Deparenting first child, reparenting it as second child results in wrong first child.");
            Assert.AreEqual(null, vd.GetSecondChild(), "Deparenting first child, reparenting it as second child results in wrong second child which should be null.");
            Assert.IsTrue(correct, "ChildrenSwitched triggered mistakenly.");
        }
Exemplo n.º 3
0
        public void ViewDataTest_GetSecondChild()
        {
            // Arrange
            cs_timed_silver.Properties.Settings.Default.AutoOpenLastFile = "No";
            var mf = new MainForm();

            mf.OnLoadCreateBasicViewDataWithView = false;
            mf.OnLoadUpdateViewType = false;

            mf.Show();

            Application.DoEvents();

            var vd = new ViewData(mf.MyDataFile);

            //var newView = new ClockListView(mf);

            // Act
            //Application.DoEvents();

            // Assert
            Assert.IsNull(vd.GetFirstChild(), "GetFirstChild should return null.");
            Assert.IsNull(vd.GetSecondChild(), "GetSecondChild should return null.");
        }