I don’t know how to use nUnit in WinRT applications(metro).
I write this code and run test (using Resharper test runner).
The test was passed. Why?
using System.Threading.Tasks;
using NUnit.Framework;
namespace UnitTestInWinRT
{
[TestFixture]
public class NUnitClassTest
{
[Test]
public void TestnUnitAsyncTest()
{
var number = GetNumberAsync(7);
number.ContinueWith(n => Assert.AreEqual("string is 6", n.Result));
}
public Task<string> GetNumberAsync(int n)
{
return Task.Run(() => "string is " + n);
}
}
}
The problem is:
You use ContinueWith method.
So, NUnit runs your lamba in other thread, and ends test method.
AssertionExcecptionoccures in other thread, that’s why test is passed.If you ran it in the same thread, test will fail as expected.