I'm trying to write a delegate with IAsyncResult type in unit test. I expect to see 2 different thread ids in output debug but I encounter this error:
System.PlatformNotSupportedException: 'Operation is not supported on this platform.'
Here is my code:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Diagnostics;
namespace UnitTest
{
[TestClass]
public class UnitTest1
{
// public delegate void stuff();
public void dowork()
{
Debug.WriteLine("Hello world");
Debug.WriteLine
(System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
}
[TestMethod]
public void demo01()
{
Debug.WriteLine
(System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
Action s = dowork;
IAsyncResult result= s.BeginInvoke(null,null);
s.EndInvoke(result);
// stuff s = new stuff(dowork);
s();
}
}
}
at this line I got that error:
IAsyncResult result= s.BeginInvoke(null,null);
I am using VS 2017. After researching I got that it works on unit test (framework), but it's not supported in unit test(.netcor). Anyone know why and any solution for that?