Mocking Objects When Using MSTest

I'm just getting started with MSTest (or at least with VS 2008 testing tools, is there a difference?)

I want to check the code that uses the session object. Obviously, I don't have an HttpContext, and I can't just create it, so the code will exit with a NullReferenceException.

Is this code just not testable?

+3
source share
4 answers

I don’t know what type of web project (MVC or WebForms) you are trying to test, but you should be able to pour out the HttpContextBase class using Scott Hanselman's bestial helpers , which have examples in Rhino.Mocks and Moq , both of which are free.

+3
source

I do not know about volatility, but it is certainly difficult to verify. You can use typemock, it can create mocks and stub practically everything. But it is not free.

. . . : , Asp.Net.

+1

, ? , , asp.net, , ( )

- ,

If UserObject.IsActive() Then
  _View.SessionActive = True
Else
  _View.SessionActive = False
End If
0

VS 2010, Microsoft Moles - .

VS 2012 Microsoft Fakes - .

0
source

Source: https://habr.com/ru/post/1704502/


All Articles