public class UnitTest1
{
// you cant use a brush because it is UI
// you switch to a UI test and it fails because it is async
// bottom line you cant test an async routine that uses a brush,
// even though your really are not doing ANY UI stuff - how stupid is that?
[TestMethod]
//[Microsoft.VisualStudio.TestPlatform.UnitTestFramework.AppContainer.UITestMethod]
async public Task TestMethod1()
{
var t = new ObservableCollection<CommentEvent>();
t.Add(new CommentEvent(Colors.LightPink) { Label = "Bad",
EventTime = TimeCode.FromTicks(DateTime.Now.Ticks,
TimeCode.SmpteFrameRate.Smpte2997Drop) });
t.Add(new CommentEvent(Colors.DarkSeaGreen) { Label = "Good",
EventTime = TimeCode.FromTicks(DateTime.Now.Ticks,
TimeCode.SmpteFrameRate.Smpte2997Drop) });
t.Add(new CommentEvent(Colors.LightPink) { Label = "Bad",
EventTime = TimeCode.FromTicks(DateTime.Now.Ticks,
TimeCode.SmpteFrameRate.Smpte2997Drop) });
t.Add(new CommentEvent(Colors.DarkSeaGreen) { Label = "Good",
EventTime = TimeCode.FromTicks(DateTime.Now.Ticks,
TimeCode.SmpteFrameRate.Smpte2997Drop) });
var s = await PreludeXMP.Get(t);
Assert.IsNotNull(s);
System.Diagnostics.Debug.WriteLine(s);
}
}
this throws a
The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)). If you are using UI objects in test consider using [UITestMethod] attribute instead of [TestMethod] to execute test in UI thread.
Because the constructor for CommentEvent creates a Solid.Brush. Any suggested workaroundsarounds?