Click here to Skip to main content
14,697,418 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm new to NUnit testing and i received the following error:
Message: System.NullReferenceException : Object reference not set to an instance of an object

my test is a follows

        public void TestCheckConsumer()
            Services check = new Services();
            CheckStockResponse response = check.CheckStock(new Credentials(), new CheckInput());
            Assert.AreEqual(Status.Registered, response);
is a mock required or can i just create sample data in the test setup
Updated 7-Aug-14 2:37am

1 solution

NUnit Tests can be debugged - try that! Visual Nunit is sometimes a bit mulish, but with patience and trying it again, it can be accomplished.
It is important to find out where the crash actually happens. Already in the constructor of Services()? Or in its CheckStock function?
Note that the .exe.config file used here is that of NUnit by default, i.e. when you need to access configuartion settings, things get a little harder to do them right.
Ignitius 11-Aug-14 4:20am
thanks for the help, i found out that the connection to the web service was not linked as it was in a web.config instead of a app.config

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900