Files
mono/mcs/class/System/Test/System.ComponentModel/AsyncOperationManagerTest.cs
T
Jonathan Pobst 7dc885163c 2007-09-25 Jonathan Pobst <[email protected]>
* SynchronizationContext.cs: Implement SetSynchronizationContext.

2007-09-25  Jonathan Pobst  <[email protected]>

	* AsyncOperationManager.cs: Tie the SynchronizationContext here to
	SynchronizationContext.Current.

2007-09-25  Jonathan Pobst  <[email protected]>

	* AsyncOperationManagerTest.cs: Add test for SynchronizationContext.

2007-09-25  Jonathan Pobst  <[email protected]>

	* System_test.dll.sources: Added AsyncOperationManagerTest.cs.

svn path=/trunk/mcs/; revision=86329
2007-09-25 14:38:37 +00:00

62 lines
1.8 KiB
C#

//
// AsyncOperationManager.cs
//
// Author:
// Jonathan Pobst <[email protected]>
//
// Copyright (C) 2007 Novell, Inc.
//
#if NET_2_0
using System;
using System.Threading;
using System.ComponentModel;
using System.Globalization;
using NUnit.Framework;
namespace MonoTests.System.ComponentModel
{
[TestFixture]
public class AsyncOperationManagerTest
{
[Test]
public void SyncContext ()
{
SynchronizationContext sc1 = new SynchronizationContext ();
SynchronizationContext sc2 = new SynchronizationContext ();
Assert.IsNull (SynchronizationContext.Current, "A1");
Assert.IsNotNull (AsyncOperationManager.SynchronizationContext, "A2");
Assert.IsNotNull (SynchronizationContext.Current, "A3");
SynchronizationContext.SetSynchronizationContext (sc1);
Assert.AreSame (sc1, SynchronizationContext.Current, "A4");
Assert.AreSame (sc1, AsyncOperationManager.SynchronizationContext, "A5");
AsyncOperationManager.SynchronizationContext = sc2;
Assert.AreSame (sc2, SynchronizationContext.Current, "A6");
Assert.AreSame (sc2, AsyncOperationManager.SynchronizationContext, "A7");
SynchronizationContext.SetSynchronizationContext (null);
Assert.IsNull (SynchronizationContext.Current, "A8");
// This is a brand new one, not sc1 or sc2
Assert.IsNotNull (AsyncOperationManager.SynchronizationContext, "A9");
Assert.IsNotNull (SynchronizationContext.Current, "A10");
AsyncOperationManager.SynchronizationContext = null;
Assert.IsNull (SynchronizationContext.Current, "A11");
// This is a brand new one, not sc1 or sc2
Assert.IsNotNull (AsyncOperationManager.SynchronizationContext, "A12");
Assert.IsNotNull (SynchronizationContext.Current, "A13");
}
}
}
#endif