This project is read-only.

Test failure using Entity in place of ValidatableValueObject

May 6, 2010 at 12:30 AM
Edited May 7, 2010 at 11:56 PM

I've noticed that a System.NullReferenceException is thrown on entity.IsValid() when the object type has been changed from ValidatableValueObject to an Entity. For example, the test when_the_profile_tasks_is_asked_to_create_a_profile tries to create a profile of type CreateProfileDetails which derives from ValidatableValueObject. If CreateProfileDetails is defined as an Entity the test throws System.NullReferenceException becasue no implementation is available for Validate() (Validate() method is null) for the Entity.

Probably a silly mistake on my part, or misunderstanding, but why would this be?


This is a stack trace:

should ask the question repository to save the new question : FailedObject reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at SharpArch.Core.DomainModel.ValidatableObject.IsValid()
at FieldAudit.Framework.Validation.ValidatableExtensions.Validate(IValidatable entity) in ValidatableExtensions.cs: line 33
at FieldAudit.Tasks.QuestionTasks.CreateQuestion(Question question) in QuestionTasks.cs: line 40
at MSpecTests.FieldAudit.Tasks.when_the_question_tasks_is_asked_to_create_a_question.<.ctor>b__2() in QuestionTasksSpecs.cs: line 137 

This is the class hierarchy:

entity = {FieldAudit.Domain.Question}
[FieldAudit.Domain.Question] = {FieldAudit.Domain.Question}
  base {SharpArch.Core.DomainModel.Entity} = {FieldAudit.Domain.Question}
    base {SharpArch.Core.DomainModel.EntityWithTypedId<int>} = {FieldAudit.Domain.Question}
      base {SharpArch.Core.DomainModel.ValidatableObject} = {FieldAudit.Domain.Question}
        Validator = null
        base {SharpArch.Core.DomainModel.BaseObject} = {FieldAudit.Domain.Question}