I have 2 classes Parent and a Child class, child class inherits from parent.
Class under test has an async method that returns Task<parent>.
I am arranging the Test method in my unit test, Mock.Arrange(() => viewmodel.Test()).Returns(Task.FromResult(new child()));
I am getting this error, Why is it having a problem in casting a child to its parenttype
ErrorCS1503Argument 1: cannot convert from 'System.Threading.Tasks.Task<ViewModels.child>' to 'System.Threading.Tasks.Task<ViewModels.parent>'ViewModels.Tests
public class viewmodel{
public async Task<parent> Test()
{
await Task.Delay(100);
return null;
}
}
public class parent
{
}
public class child : parent
{
}