Add an async-compatible Assert.ThrowsException
Win8 replaced ExpectedExceptionAttribute with Assert.ThrowsException. This is good, but there isn't an equivalent Assert.ThrowsExceptionAsync for async delegates.
Something like this would be fine:
public static async Task ThrowsExceptionAsync<TException>(Func<Task> action, bool allowDerivedTypes = true)
Assert.Fail("Delegate did not throw expected exception " + typeof(TException).Name + ".");
catch (Exception ex)
if (allowDerivedTypes && !(ex is TException))
Assert.Fail("Delegate threw exception of type " + ex.GetType().Name + ", but " + typeof(TException).Name + " or a derived type was expected.");
if (!allowDerivedTypes && ex.GetType() != typeof(TException))
Assert.Fail("Delegate threw exception of type " + ex.GetType().Name + ", but " + typeof(TException).Name + " was expected.");
Chris McClellan commented
Broken as all get out for UWP. No wonder no one's developing for UWP. MS is treating it like a second class citizen. If I can't test my code, there's no point in writing it to begin with.
Stephen Cleary commented
The update only affects Windows Store test projects. All other unit test projects still do not have this capability.
Howard Richards commented
Microsoft was listening- this being fixed in update 2: see http://support.microsoft.com/kb/2797912