Ejemplo n.º 1
0
        public void RunTestProcessContextData(IRemoteObject testerSurrogate)
        {
            CallContext.FreeNamedDataSlot("clientData");
            CallContext.FreeNamedDataSlot("serverData");
            CallContext.FreeNamedDataSlot("mustNotPass");

            // First step

            ContextData cdata = new ContextData();

            cdata.data     = "hi from client";
            cdata.id       = 1123;
            cdata.testStep = 1;
            CallContext.SetData("clientData", cdata);
            CallContext.SetData("mustNotPass", "more data");

            testerSurrogate.ProcessContextData();

            cdata = CallContext.GetData("clientData") as ContextData;
            Assert.IsNotNull(cdata, "clientData is null");
            Assert.AreEqual("hi from client", cdata.data, "clientData.data");
            Assert.AreEqual(1123, cdata.id, "clientData.id");

            cdata = CallContext.GetData("serverData") as ContextData;
            Assert.IsNotNull(cdata, "serverData is null");
            Assert.AreEqual("hi from server", cdata.data, "serverData.data");
            Assert.AreEqual(3211, cdata.id, "serverData.id");

            string mdata = CallContext.GetData("mustNotPass") as string;

            Assert.IsNotNull(mdata, "mustNotPass is null");
            Assert.AreEqual("more data", mdata, "mustNotPass");

            // Second step. Test that exceptions return the call context.

            CallContext.FreeNamedDataSlot("clientData");
            CallContext.FreeNamedDataSlot("serverData");

            cdata          = new ContextData();
            cdata.data     = "hi from client";
            cdata.id       = 1123;
            cdata.testStep = 2;
            CallContext.SetData("clientData", cdata);

            try {
                testerSurrogate.ProcessContextData();
                Assert.Fail("Exception not thrown");
            } catch (Exception ex) {
                if (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                if (ex.Message != "exception from server")
                {
                    throw;
                }
            }

            cdata = CallContext.GetData("clientData") as ContextData;
            Assert.IsNotNull(cdata, "clientData is null (2)");
            Assert.AreEqual("hi from client", cdata.data, "clientData.data (2)");
            Assert.AreEqual(1123, cdata.id, "clientData.id (2)");

            mdata = CallContext.GetData("mustNotPass") as string;
            Assert.IsNotNull(mdata, "mustNotPass is null");
            Assert.AreEqual("more data", mdata, "mustNotPass");
        }
Ejemplo n.º 2
0
		public void RunTestProcessContextData (IRemoteObject testerSurrogate)
		{
			CallContext.FreeNamedDataSlot ("clientData");
			CallContext.FreeNamedDataSlot ("serverData");
			CallContext.FreeNamedDataSlot ("mustNotPass");

			ContextData cdata = new ContextData ();
			cdata.data = "hi from client";
			cdata.id = 1123;
			CallContext.SetData ("clientData", cdata);
			CallContext.SetData ("mustNotPass", "more data");
			
			testerSurrogate.ProcessContextData ();
			
			cdata = CallContext.GetData ("clientData") as ContextData;
			Assert.IsNotNull (cdata, "clientData is null");
			Assert.AreEqual ("hi from client", cdata.data, "clientData.data");
			Assert.AreEqual (1123, cdata.id, "clientData.id");
			
			cdata = CallContext.GetData ("serverData") as ContextData;
			Assert.IsNotNull (cdata, "serverData is null");
			Assert.AreEqual ("hi from server", cdata.data, "serverData.data");
			Assert.AreEqual (3211, cdata.id, "serverData.id");
			
			string mdata = CallContext.GetData ("mustNotPass") as string;
			Assert.IsNotNull (mdata, "mustNotPass is null");
			Assert.AreEqual ("more data", mdata, "mustNotPass");
		}
Ejemplo n.º 3
0
		public override void ProcessContextData ()
		{
			ContextData cdata = CallContext.GetData ("clientData") as ContextData;
			if (cdata == null) 
				throw new Exception ("server: clientData is null");
			if (cdata.data != "hi from client" || cdata.id != 1123)
				throw new Exception ("server: clientData is not valid");
			
			cdata = new ContextData ();
			cdata.data = "hi from server";
			cdata.id = 3211;
			CallContext.SetData ("serverData", cdata);
			
			string mdata = CallContext.GetData ("mustNotPass") as string;
			if (mdata != null) throw new Exception ("mustNotPass is not null");
		}
Ejemplo n.º 4
0
		public void RunTestProcessContextData (IRemoteObject testerSurrogate)
		{
			CallContext.FreeNamedDataSlot ("clientData");
			CallContext.FreeNamedDataSlot ("serverData");
			CallContext.FreeNamedDataSlot ("mustNotPass");
			
			// First step

			ContextData cdata = new ContextData ();
			cdata.data = "hi from client";
			cdata.id = 1123;
			cdata.testStep = 1;
			CallContext.SetData ("clientData", cdata);
			CallContext.SetData ("mustNotPass", "more data");
			
			testerSurrogate.ProcessContextData ();
			
			cdata = CallContext.GetData ("clientData") as ContextData;
			Assert.IsNotNull (cdata, "clientData is null");
			Assert.AreEqual ("hi from client", cdata.data, "clientData.data");
			Assert.AreEqual (1123, cdata.id, "clientData.id");
			
			cdata = CallContext.GetData ("serverData") as ContextData;
			Assert.IsNotNull (cdata, "serverData is null");
			Assert.AreEqual ("hi from server", cdata.data, "serverData.data");
			Assert.AreEqual (3211, cdata.id, "serverData.id");
			
			string mdata = CallContext.GetData ("mustNotPass") as string;
			Assert.IsNotNull (mdata, "mustNotPass is null");
			Assert.AreEqual ("more data", mdata, "mustNotPass");
			
			// Second step. Test that exceptions return the call context.
			
			CallContext.FreeNamedDataSlot ("clientData");
			CallContext.FreeNamedDataSlot ("serverData");
			
			cdata = new ContextData ();
			cdata.data = "hi from client";
			cdata.id = 1123;
			cdata.testStep = 2;
			CallContext.SetData ("clientData", cdata);
			
			try {
				testerSurrogate.ProcessContextData ();
				Assert.IsTrue (false, "Exception not thrown");
			} catch (Exception ex) {
				if (ex.InnerException != null)
					ex = ex.InnerException;
				if (ex.Message != "exception from server")
					throw;
			}
			
			cdata = CallContext.GetData ("clientData") as ContextData;
			Assert.IsNotNull (cdata, "clientData is null (2)");
			Assert.AreEqual ("hi from client", cdata.data, "clientData.data (2)");
			Assert.AreEqual (1123, cdata.id, "clientData.id (2)");
			
			mdata = CallContext.GetData ("mustNotPass") as string;
			Assert.IsNotNull (mdata, "mustNotPass is null");
			Assert.AreEqual ("more data", mdata, "mustNotPass");
		}