Answer the question
In order to leave comments, you need to log in
How to use cookies in xUnit?
I wrote an Action of some controller, as well as a test for it. The problem is that the Action uses the value from the cookie, and the test, when trying to execute this Action, throws an error System.NullReferenceException : Object reference not set to an instance of an object. on the line with cookies. How can I write a test for my Action without changing it, and does this mean that I'm doing something wrong and my application architecture is bad?
Answer the question
In order to leave comments, you need to log in
controller.Response.Cookies.Append("Company", new Mock<string>().Object);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question