public void Test_Proxy() { int result = 0; ISubject mySubject = new MySubject(); result = mySubject.Request("param1"); Assert.AreEqual(1, result); ISubject myProxy = new MyProxy(mySubject); // adds 1000 for each proxy call result = myProxy.Request("param2"); Assert.AreEqual(1001, result); result = myProxy.Request("param3"); Assert.AreEqual(2001, result); result = myProxy.Request(""); Assert.AreEqual(3001, result); }
/// <summary> /// 代理模式 /// </summary> static void TestProxy() { MyProxy myProxy = new MyProxy(); myProxy.Request(); }
void Start() { MyProxy myProxy = new MyProxy(); myProxy.Request(); }