C# - how to create a successfully completed tasks with a result

Tasks can be a bit of a pain when writing tests. Often when a dependency returns a task, it is often enough just to return a completed one. This can be done easily with a one-liner in c#. Using Task.FromResult() you can easily get a successfully completed task with a result:

var completedTask = Task.FromResult<string>("SomeResult");

The above Creates and completes a task in the same line. You can then go ahead and use .Result to get the returned string. I hope this helps someone out there! Let me know if it did.