TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
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
Forums
Monthly Leaders
Forum guidelines
Ankit Agarwal
NA
379
254.3k
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