Exemplo n.º 1
0
        public void FunctionExecuteTest()
        {
            Function func = new TestFunc();

            // f(x, y) = x^2 + 3x + y^2 + 4
            // f(1, 2) = 1^2 + 3*1 + 2^2 + 4 = 12
            double expected = 12;
            double actual   = func.Execute(1, 2);

            // テスト
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void FunctionOrderTest()
        {
            Function    func     = new TestFunc();
            PrivateType prvt_obj = new PrivateType(typeof(TestFunc));

            // フィールドの取得
            int order = func.Order;
            int ORDER = (int)prvt_obj.GetStaticField("ORDER");

            // テスト
            Assert.AreEqual(ORDER, order);
        }
Exemplo n.º 3
0
        public void FunctionUnknownTest()
        {
            Function    func     = new TestFunc();
            PrivateType prvt_obj = new PrivateType(typeof(TestFunc));

            // フィールドの取得
            int unknown = func.Unknown;
            int UNKNOWN = (int)prvt_obj.GetStaticField("UNKNOWN");

            // テスト
            Assert.AreEqual(UNKNOWN, unknown);
        }
Exemplo n.º 4
0
        public void FunctionConstructorTest()
        {
            Function      func           = new TestFunc();
            PrivateObject prvt_obj_super = new PrivateObject(func, new PrivateType(typeof(Function)));
            PrivateType   prvt_obj_sub   = new PrivateType(typeof(TestFunc));

            // フィールドの取得
            int order   = (int)prvt_obj_super.GetField("order");
            int unknown = (int)prvt_obj_super.GetField("unknown");
            int ORDER   = (int)prvt_obj_sub.GetStaticField("ORDER");
            int UNKNOWN = (int)prvt_obj_sub.GetStaticField("UNKNOWN");

            // テスト
            Assert.AreEqual(ORDER, order);
            Assert.AreEqual(UNKNOWN, unknown);
        }