I'm thinking, while writing some unit tests for an application to build intuitive methods into my classes that renders differently depending on which "class" called the method.
So, I'm in an NUnit class, and need to test whether a FormsAuthenticationTicket
was successfully created for the authenticated user:
Assert.DoesNotThrow(typeof(Application.AuthenticationFailure),
delegate { Code.Authenticate(); }
Problem I'm facing is HttpContext is not valid in unit tests. Found several solutions but like what Phil Haack did with his HttpSimulator. This does not work directly within my unit test code, as I'm mocking EF classes (not recommended I know), and the simulator affects the connection strings.
It is a better option to rather move the data calls out of the unit tests, but I'm learning about anonymous methods in the process and would like to do something like:
delegate<Test> { AuthenticateSimulate(customer); }
Is there a nice alternative in 3.5 to do something like this?