You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is not possible to return different return values of type task. I receive always the same task. If the method returns "string" instead of "Task<string>", it works well!
The following test is a infinite loop:
public interface ITest
{
Task<string> Write();
}
public class Test
{
private readonly ITest test;
public Test(ITest test)
{
this.test = test;
}
public void Write()
{
var result = test.Write().Result;
while (result != "")
{
Console.WriteLine(result);
result = test.Write().Result;
}
}
}
[TestMethod]
public void TaskTest()
{
var queue = new Queue<string>();
queue.Enqueue("qq");
queue.Enqueue("");
var mock = new Mock<ITest>();
mock.Setup(item => item.Write()).Returns(Task.Run(() => queue.Dequeue()));
var test = new Test(mock.Object);
test.Write();
}
The text was updated successfully, but these errors were encountered:
It is not possible to return different return values of type task. I receive always the same task. If the method returns "string" instead of "Task
<string>
", it works well!The following test is a infinite loop:
The text was updated successfully, but these errors were encountered: