Creating Moqs and attempting to return sequences of results for Async methods
Uses mock.Setup with Returns method, returning a delegate for a method that returns a Task of the appropriate type, utilizing the Queue object type and an extension method to return the Task
Expects to return odd numbers 1-7
1
3
5
7
Uses mock.SetupSequence with Returns method, returning a delegate for a method that returns a Task of the appropriate type, utilizing the Queue object type and an extension method to return the Task
Expected to return 2, then error message
2
One or more errors occurred. (Object reference not set to an instance of an object.)
Uses mock.SetupSequence, capturing the fluent api object returned by SetupSequence, then looping through the list of expected return objects and calling ReturnsAsync on the fluent api object for each expected result, utilizing the Queue object type and an extension method to return the Task
Expected to return odd numbers 3-9
3
5
7
9
Uses mock.Setup with Returns method, returning a delegate for a method that returns a Task of the appropriate type, utilizing the AsyncQueue object type
Expected to return even numbers 4-10
4
6
8
10
Uses mock.SetupSequence with Returns method, returning a delegate for a method that returns a Task of the appropriate type, utilizing the AsyncQueue object type
Expected to immediatly throw an error message
One or more errors occurred. (Invalid callback. Setup on method with 0 parameter(s) cannot invoke callback with different number of parameters (1).)
Uses mock.Setup with Returns method, returning a delegate for a method that returns a Task of the appropriate type, utilizing the Queue object type and an extension method to return the Task, attempts to return more results than have been queued
Expected to return odd numbers 1-7, then Queue empty error
1
3
5
7
One or more errors occurred. (Queue empty.)
Uses mock.SetupSequence with ReturnsAsync method, returning a delegate for a method that returns a Task of the appropriate type, utilizing the Queue object type and an extension method to return the Task, attempts to return more results than have been queued
Expected to return odd numbers 1-7, then Null Reference error
1
3
5
7
One or more errors occurred. (Object reference not set to an instance of an object.)
Uses mock.SetupSequence with ReturnsAsync method, returning a delegate for a method that returns a Task of the appropriate type, utilizing the Queue object type and an extension method to return the Task, attempts to return more results than have been queued, adds a default setup
Expected to return even numbers 2-10
2
4
6
8
10