示例#1
0
        public void CreateInstanceTest()
        {
            var   pb    = new ProxyBuilder();
            var   proxy = pb.CreateProxyOf <F**k>();
            ILake lake  = new ChinaLake();

            lake.RegisterSingleton <ILake>(lake);
            proxy.Lakes.Add(lake);
            proxy.CreateInstance(new Dictionary <string, object>()
            {
                { "test", 1 }, { "test2", "c" }
            });
            Assert.IsTrue(proxy.Instance != null);
            Assert.IsTrue(proxy.Instance.Test == 1);
            Assert.IsTrue(proxy.Instance.Test2 == "c");
            Assert.IsTrue(proxy.Instance.Lake == lake);
        }
示例#2
0
        public void InvokeMethodTest()
        {
            var   pb    = new ProxyBuilder();
            var   proxy = pb.CreateProxyOf(typeof(InvokeClass));
            ILake lake  = new ChinaLake();

            lake.RegisterSingleton <ILake>(lake);
            proxy.Lakes.Add(lake);
            proxy.CreateInstance();
            var invokeSuccess = false;
            var callback      = new Action <string, ILake>((a, _lake) =>
            {
                invokeSuccess = a != null && _lake != null;
            });

            proxy.InvokeMethod("F**k", new Dictionary <string, object>()
            {
                { "a", "b" }, { "callback", callback }
            });
            Assert.IsTrue(invokeSuccess);
        }