0

I am unit testing a Post method that in its implementation uses a

 Microsoft.AspNet.Identity.Owin.SignInManager

because SignInManager inherit from a class and not an interface I cannot use NSubstitute to mock the SignInManager object. Therefore I cannot use the ReturnForAnyArgs method to get it to return a SignInStatus of say Success.

Is there any way of returning for any arguments without using NSubstitute?

Marta
  • 1,132
  • 1
  • 10
  • 26

1 Answers1

1

SignInManager has some virtual methods, which NSubstitute will be able to mock (keeping in mind that some real code will execute because it is a class with some non-virtual members). Or you could wrap the features you need from SignInManager with your own interface, mock that in tests, and use an adapter class to provide an implementation that uses SignInManager under the hood.

I also found some info on mocking custom sign-in stuff under the "Use in a Controller" heading that may help.

David Tchepak
  • 9,826
  • 2
  • 56
  • 68
  • We used this http://www.codeproject.com/Articles/342082/Understanding-and-Implementing-the-Adapter-Pattern to create an ISignInManager and an adapter class that implements it. – Marta Mar 18 '15 at 15:49