예제 #1
0
        public void Class()
        {
            Assert.That(Utils.Object.DoesClassExist("First.Person"), Is.True, "De Class Person bestaat niet.");

            var person = new Utils.Object("First.Person");

            person.AssertClass();
        }
예제 #2
0
        public void Class()
        {
            Assert.That(Utils.Object.DoesClassExist("First.ScoreBoard"), Is.True, "De Class ScoreBoard bestaat niet.");

            var board = new Utils.Object("First.ScoreBoard");

            board.AssertClass();
        }
예제 #3
0
 public void TestOefening2()
 {
     Utils.Object Obj = new Utils.Object("First.Oefenreeks1");
     Obj.AssertClass();
     Obj.AssertMethod(First.Program.ISPOS, typeof(bool), new Type[] { typeof(float) });
     Assert.That(Obj.Method(First.Program.ISPOS, typeof(float)).Invoke(5.67f), Is.True, "Getallen groter dan nul zijn positief");
     Assert.That(Obj.Method(First.Program.ISPOS, typeof(float)).Invoke(-12f), Is.False, "Negatieve getallen zijn kleiner dan null");
 }
예제 #4
0
        public void DateOfBirth()
        {
            var person = new Utils.Object("First.Person");

            if (person.AssertClass())
            {
                person.AssertProperty("DateOfBirth", Utils.PropertyAccess.ReadWrite, typeof(DateTime));
            }
        }
예제 #5
0
        public void LastName()
        {
            var person = new Utils.Object("First.Person");

            if (person.AssertClass())
            {
                person.AssertProperty("LastName", Utils.PropertyAccess.ReadWrite, typeof(string));
            }
        }
예제 #6
0
        public void Player2Name()
        {
            var board = new Utils.Object("First.ScoreBoard");

            if (board.AssertClass())
            {
                board.AssertProperty("Player2Name", Utils.PropertyAccess.ReadWrite, typeof(string));
            }
        }
예제 #7
0
        public void Player2Score()
        {
            var board = new Utils.Object("First.ScoreBoard");

            if (board.AssertClass())
            {
                board.AssertProperty("Player2Score", Utils.PropertyAccess.ReadOnly, typeof(int));
            }
        }
예제 #8
0
        public void TestOefening5()
        {
            Utils.Object Obj = new Utils.Object("First.Oefenreeks1");
            Obj.AssertClass();
            Obj.AssertMethod(First.Program.OPPRH, typeof(float), new Type[] { typeof(float), typeof(float) });

            Assert.That(Obj.Method(First.Program.OPPRH, new Type[] { typeof(float), typeof(float) }).Invoke(new object[] { 4.1f, 5f }), Is.EqualTo(20.5f).Within(.0005), "Foute Berekening");
            Assert.That(Obj.Method(First.Program.OPPRH, new Type[] { typeof(float), typeof(float) }).Invoke(new object[] { 1.1f, 3.4f }), Is.EqualTo(3.74f).Within(.0005), "Foute Berekening");
        }
예제 #9
0
        public void TestOefening4()
        {
            Utils.Object Obj = new Utils.Object("First.Oefenreeks1");
            Obj.AssertClass();
            Obj.AssertMethod(First.Program.OPPRH, typeof(int), new Type[] { typeof(int), typeof(int) });

            Assert.That(Obj.Method(First.Program.OPPRH, new Type[] { typeof(int), typeof(int) }).Invoke(new object[] { 4, 5 }), Is.EqualTo(20), "Foute Berekening");
            Assert.That(Obj.Method(First.Program.OPPRH, new Type[] { typeof(int), typeof(int) }).Invoke(new object[] { 14, 10 }), Is.EqualTo(140), "Foute Berekening");
        }
예제 #10
0
        public void TestOefening10()
        {
            Utils.Object Obj = new Utils.Object("First.Oefenreeks1");
            Obj.AssertClass();
            Obj.AssertMethod(First.Program.DECR, typeof(void), new Type[] { typeof(int[]), typeof(int) });

            int[] arr  = { 5, 6, 7, 8 };
            int[] arr2 = { 0, 1, 2, 3 };
            Obj.Method(First.Program.DECR, new Type[] { typeof(int[]), typeof(int) }).Invoke(new object[] { arr, 5 });
            Assert.That(ArraysAreEqual(arr, arr2), Is.True, "De verlaging is niet correct");
        }
예제 #11
0
        public void Age()
        {
            var person = new Utils.Object("First.Person");

            if (person.AssertClass())
            {
                person.AssertMethod("Age", typeof(int));
            }

            Random gen = new Random();

            for (int i = 0; i < 10; i++)
            {
                DateTime start = new DateTime(1900, 1, 1);
                int      range = (DateTime.Today - start).Days;

                var myDate = start.AddDays(gen.Next(range));
                person.Prop("DateOfBirth")?.Set(myDate);

                int expectedAge = (DateTime.Now.Year - myDate.Year) - 1;
                if (DateTime.Now.Month > myDate.Month)
                {
                    expectedAge++;
                }
                else if (DateTime.Now.Month == myDate.Month &&
                         DateTime.Now.Day >= myDate.Day)
                {
                    expectedAge++;
                }

                var calculatedAge = (int)person.Method("Age")?.Invoke();
                Assert.That(calculatedAge, Is.EqualTo(expectedAge), "De berekening van de leeftijd is niet juist");
                if (calculatedAge != expectedAge)
                {
                    break;                                               // no need to continue after an error
                }
            }
        }