コード例 #1
0
        public void showConstraintsTest()
        {
            // Test obj (form)
            Globals._session = testInputStudent;
            StudentScheduler StudentSchedulerForm = new StudentScheduler(testInputStudent);
            Control          warpper = (Control)(typeof(StudentScheduler).GetField("warpper", this.bf).GetValue(StudentSchedulerForm));

            StudentSchedulerForm.showConstraints();
            StudentSchedulerForm.Show();

            // create button for testing
            foreach (string constrain in testInputStudent.Constraints.Split(';'))
            {
                if (constrain == "")
                {
                    continue;
                }
                MatchCollection match = Regex.Matches(constrain, @"[0-9]+");
                int             col   = int.Parse(match[0].ToString());
                int             row   = int.Parse(match[1].ToString());
                MetroTile       c     = new MetroTile();
                c.Name = "const_" + col + "_" + row;

                // test const btns after showConstraints() function run
                Control[] const_arr = warpper.Controls.Find(c.Name, false);
                Assert.IsTrue(const_arr.Length == 1);
            }

            StudentSchedulerForm.Close();
        }
コード例 #2
0
        public void BringBtnsToFrontTest()
        {
            // prep
            Globals._session = testInputStudent;
            StudentScheduler StudentSchedulerForm = new StudentScheduler(null);


            // Test this.warpper.Controls should not contain 'const_' named btns
            Control warpper = (Control)(typeof(StudentScheduler).GetField("warpper", this.bf).GetValue(StudentSchedulerForm));

            foreach (Control a in warpper.Controls)
            {
                foreach (Control b in warpper.Controls)
                {
                    if (a.Name.Contains("ev_"))
                    {
                        Assert.IsTrue(warpper.Controls.GetChildIndex(a) > warpper.Controls.GetChildIndex(b));
                    }
                }
            }
        }
コード例 #3
0
        public void StudentSchedulerTest()
        {
            // Test obj (form)
            StudentScheduler StudentSchedulerForm = new StudentScheduler(testInputStudent);

            // test that input variable assinged
            Student StudentResult = (Student)(typeof(StudentScheduler).GetField("currentStudent", this.bf).GetValue(StudentSchedulerForm));

            // TEST currentStudent != null
            Assert.AreEqual(testInputStudent, StudentResult);


            // test that if input is null, ctor sets global as current
            Globals._session     = testInputStudent;
            StudentSchedulerForm = new StudentScheduler(null);
            Student GlobalStudentResult = (Student)(typeof(StudentScheduler).GetField("currentStudent", this.bf).GetValue(StudentSchedulerForm));

            // TEST currentStudent == null
            Assert.AreEqual(Globals._session, GlobalStudentResult);

            // TEST currentStudent == null &&  Globals._session = null
            Globals._session     = null;
            StudentSchedulerForm = new StudentScheduler(null);
        }