Пример #1
0
        public void AddTargetObjectTest()
        {
            var env = new RPCExecutor();

            var cla = new TestClassA();

            env.AddTargetObject(cla);

            var req    = new RPCRequest(typeof(int), nameof(TestClassA.Add1), 1);
            var result = env.Invoke(req);

            Assert.AreEqual(2, result);
        }
Пример #2
0
        public void ScopeInjectionTest()
        {
            var env = new RPCExecutor();

            var cla = new TestClassA();

            env.AddTargetObject(cla);

            var req    = new RPCRequest(typeof(int), nameof(TestClassA.Add2), 1);
            var result = env.Invoke(req, new object[] { new TestClassB(2) });

            Assert.AreEqual(3, result);
        }
Пример #3
0
        public void ExecuteSpecMethodTest()
        {
            var env = new RPCExecutor();

            var cla = new TestClassA();

            env.AddSingleton(cla);
            env.AddTargetMethod <TestClassA>(x => x.Add1(1));

            var req    = new RPCRequest(typeof(int), nameof(TestClassA.Add1), 1);
            var result = env.Invoke(req);

            Assert.AreEqual(2, result);
        }
Пример #4
0
        public void GlobalInjectionTest()
        {
            var env = new RPCExecutor();

            var cla = new TestClassA();

            env.AddTargetObject(cla);

            env.AddSingleton(new TestClassC(3));

            var req    = new RPCRequest(typeof(int), nameof(TestClassA.Add3), 1);
            var result = env.Invoke(req, new object[] { new TestClassB(2) });

            Assert.AreEqual(6, result);
        }