Want to build the ChatGPT based Apps? Start here
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Ankit Agarwal
1.8k
379
234.5k
Getting null reference error during Unit Testing withsession
Jul 6 2018 7:25 AM
Hello,
When i am running my Unit Test project,so its getting error from mvc application"
System.NullReferenceException: 'Object reference not set to an instance of an object.'
System.Web.HttpContext.Current.get returned null.
I have tried in MVC Application.
Please help me and tell me the whole process of UnitTesting in MVC. With maintenance of System.Web.HttpContext.Currect.Session.
I have tried following code:-
//Arrange
GCopaDimensionsController gCopaDimensionsController = new GCopaDimensionsController();
//gCopaDimensionsController.ControllerContext = context.Object;
//Act
ViewResult result = gCopaDimensionsController.Index() as ViewResult;
//Assert
Assert.AreEqual("Manage Global Copa Dimension", gCopaDimensionsController.Session["Title"]);
//Assert.Fail();
Thanks in Advance.
Ankit Agarwal
Software Engineer
Reply
Answers (
2
)
Visual Studio code
Remove alphanumeric from string