I have used Microsoft Unit testing to test one of my DNN modules (called Corporation). In the Unit Test project I have App_Code folder where are DataProvider.vb and SqlDataProvider.vb. The code of the test is very simple:
<TestClass()> Public Class UnitTestDNN
<TestMethod()> Public Sub FirstUnitTest()
Dim contr As New IGD.Corporation.CorporationController
Dim objTest As IGD.Corporation.Corporation
objTest = New IGD.Corporation.Corporation
objTest.id = 0
objTest.description = "TestDescription"
objTest.email = "[email protected]"
objTest.Website = "www.test.org"
objTest.cell = "404-555-0110"
objTest.phone = "404-555-0110"
objTest.fax = "404-555-0110"
objTest.Zip = "30301"
objTest.state = "US"
objTest.country = "GA"
'objTest.Zip = "30301"
objTest.address = "TestAddress"
objTest.name = "TestName"
objTest.city = "Atlanta"
objTest.Disabled = False
objTest.logo = String.Empty
'objTest = contr.GetCorporation(6)
If objTest IsNot Nothing Then
If contr IsNot Nothing Then
objTest.id = contr.SaveCorporation(objTest)
Dim corpC As New IGD.Corporation.CorporationController
Dim corp As IGD.Corporation.Corporation = corpC.GetCorporation(objTest.id)
The code for SaveCorporation is:
Public Function SaveCorporation(ByVal obj As IGD.Corporation.Corporation) As Integer
But, during debugging I have received the bug into SaveCorporation method: "Object reference not set to an instance of an object", although the objTest has values in all properties, and I can see them in debugger. How can I solve this? Thank you in advance for any help.