X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FTest%2FSystem.Threading%2FExecutionContextTest.cs;h=2fa3d91a04fcd6512470d47c00c270ea9d5d0a33;hb=5e4093ab13c236eeb250cae17323bee655ccc936;hp=0062dbe8cd0131260398970fbd52709478c5a3d2;hpb=04d1b4116331e3813b8f75304f714a5d61ba1214;p=mono.git diff --git a/mcs/class/corlib/Test/System.Threading/ExecutionContextTest.cs b/mcs/class/corlib/Test/System.Threading/ExecutionContextTest.cs index 0062dbe8cd0..2fa3d91a04f 100644 --- a/mcs/class/corlib/Test/System.Threading/ExecutionContextTest.cs +++ b/mcs/class/corlib/Test/System.Threading/ExecutionContextTest.cs @@ -25,6 +25,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +using System.Runtime.Remoting.Messaging; #if NET_2_0 @@ -46,6 +47,15 @@ namespace MonoTests.System.Threading { success = (bool)o; } + public class CallContextValue : ILogicalThreadAffinative { + public object Value { get; set; } + + public CallContextValue (object value) + { + this.Value = value; + } + } + [SetUp] public void SetUp () { @@ -57,9 +67,92 @@ namespace MonoTests.System.Threading { { if (ExecutionContext.IsFlowSuppressed ()) ExecutionContext.RestoreFlow (); + + CallContext.FreeNamedDataSlot ("testlc"); + } + + [Test] + [Category("MobileNotWorking")] + public void LogicalGetData_SetData() + { + var value = "a"; + + CallContext.SetData ("testlc", value); + var capturedValue = CallContext.LogicalGetData ("testlc"); + + Assert.IsNull (capturedValue); + } + + [Test] + [Category("MobileNotWorking")] + public void LogicalGetData_SetDataLogicalThreadAffinative() + { + var value = new CallContextValue ("a"); + + CallContext.SetData ("testlc", value); + var capturedValue = CallContext.LogicalGetData ("testlc"); + + Assert.AreEqual (value, capturedValue); + } + + [Test] + [Category("MobileNotWorking")] + public void GetData_SetLogicalData() + { + var value = "a"; + + CallContext.LogicalSetData ("testlc", value); + var capturedValue = CallContext.GetData ("testlc"); + + Assert.AreEqual (value, capturedValue); + } + + [Test] + [Category("MobileNotWorking")] + public void CaptureLogicalCallContext() + { + var value = "Tester"; + object capturedValue = null; + + CallContext.LogicalSetData ("testlc", value); + + ExecutionContext ec = ExecutionContext.Capture (); + Assert.IsNotNull (ec, "Capture"); + Assert.AreEqual (value, CallContext.LogicalGetData ("testlc")); + CallContext.LogicalSetData ("testlc", null); + + ExecutionContext.Run (ec, new ContextCallback (new Action ((data) => { + capturedValue = CallContext.LogicalGetData ("testlc"); + })), null); + + Assert.AreEqual (value, capturedValue); + Assert.AreNotEqual (value, CallContext.LogicalGetData ("testlc")); + } + + [Test] + [Category ("MobileNotWorking")] + public void CaptureCallContext () + { + var value = new CallContextValue (true); + object capturedValue = null; + + CallContext.SetData ("testlc", value); + + ExecutionContext ec = ExecutionContext.Capture (); + Assert.IsNotNull (ec, "Capture"); + Assert.AreEqual (value, CallContext.GetData ("testlc")); + CallContext.SetData ("testlc", null); + + ExecutionContext.Run (ec, new ContextCallback (new Action ((data) => { + capturedValue = CallContext.GetData ("testlc"); + })), null); + + Assert.AreEqual (value, capturedValue); + Assert.AreNotEqual (value, CallContext.GetData ("testlc")); } [Test] + [Category("MobileNotWorking")] public void Capture () { ExecutionContext ec = ExecutionContext.Capture (); @@ -77,6 +170,7 @@ namespace MonoTests.System.Threading { } [Test] + [Category("MobileNotWorking")] public void Copy () { ExecutionContext ec = ExecutionContext.Capture (); @@ -95,6 +189,8 @@ namespace MonoTests.System.Threading { [Test] [ExpectedException (typeof (InvalidOperationException))] + // The context might be the result of capture so no exception is thrown + [Category ("NotWorking")] public void Copy_FromThread () { ExecutionContext ec = Thread.CurrentThread.ExecutionContext; @@ -104,6 +200,7 @@ namespace MonoTests.System.Threading { } [Test] + [Category("MobileNotWorking")] public void IsFlowSuppressed () { Assert.IsFalse (ExecutionContext.IsFlowSuppressed (), "IsFlowSuppressed-1"); @@ -117,12 +214,14 @@ namespace MonoTests.System.Threading { [Test] [ExpectedException (typeof (InvalidOperationException))] + [Category("MobileNotWorking")] public void RestoreFlow_None () { ExecutionContext.RestoreFlow (); } [Test] + [Category("MobileNotWorking")] public void RestoreFlow_SuppressFlow () { Assert.IsFalse (ExecutionContext.IsFlowSuppressed (), "IsFlowSuppressed-1"); @@ -143,6 +242,7 @@ namespace MonoTests.System.Threading { [Test] [ExpectedException (typeof (InvalidOperationException))] + [Category("MobileNotWorking")] public void Run_SuppressFlow () { Assert.IsFalse (ExecutionContext.IsFlowSuppressed ()); @@ -157,6 +257,7 @@ namespace MonoTests.System.Threading { } [Test] + [Category("MobileNotWorking")] public void SuppressFlow () { Assert.IsFalse (ExecutionContext.IsFlowSuppressed (), "IsFlowSuppressed-1"); @@ -170,6 +271,7 @@ namespace MonoTests.System.Threading { [Test] [ExpectedException (typeof (InvalidOperationException))] + [Category("MobileNotWorking")] public void SuppressFlow_Two_Undo () { Assert.IsFalse (ExecutionContext.IsFlowSuppressed (), "IsFlowSuppressed-1");