Umbraco 7.6.3 Tests to Controller always fails

124 Views Asked by At

I have a serious issue with testings on Umbraco 7.6.3 because my test always get the same error:

System.NullReferenceException : Object reference not set to an instance of an object.

   at DirectUmbraco.Models.ContactModel..ctor() in E:\Projects\Umbraco\DirectUmbraco\DirectUmbraco\Models\ContactModel.cs:line 13
   at DirectUmbraco.Tests.FormsControllerTests.TestContactMethod() in E:\Projects\Umbraco\DirectUmbraco\DirectUmbraco.Tests\ControllersTests.cs:line 43

line 43 refers to my ContactModel constructor (inherited from Umbraco.Web.Models.RenderModel ) and My Controllers are inherited from SurfaceController.

public ContactModel()
            :base(UmbracoContext.Current.PublishedContentRequest.PublishedContent){
        }

An this is my test method:

[Test]
        public void TestContactMethod()
        {
            var controller= new FormController(); //until this the test pass OK
            var contactModel = new ContactModel(); //Here the Exception is thrown
            var response = controller.Contact(contactModel);
            Assert.IsNotNull(response);
        }

I 've checked some related content here and here too but no one with lucky. What can I do to solve this?

Thank you.

0

There are 0 best solutions below