Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 785449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:52:49+00:00 2026-05-14T20:52:49+00:00

I’m working with a test project based on WhoCanHelpMe, which is based on Sharp

  • 0

I’m working with a test project based on WhoCanHelpMe, which is based on Sharp Architecture, NHibernateValidator, etc. As its written the when_the_profile_tasks_is_asked_to_create_a_profile unit test creates the profile object and saves it without issue.

Now the profile object is a CreateProfileDetails type that derives from their own ValidatableValueObject which inherits the IValidatable interface.

The problem surfaces when my class is based on an Entity rather than their ValidatableValueObject. When the test is run a System.NullReferenceException because Validator is null.

I’m afraid that I’m at a loss to resolve this bad behavior. Does anyone have some suggestions to get to the bottom of this?

Thanks,

-Ted-

This is the 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.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} = {FieldAudit.Domain.Question}
      base {SharpArch.Core.DomainModel.ValidatableObject} = {FieldAudit.Domain.Question}
        Validator = null
        base {SharpArch.Core.DomainModel.BaseObject} = {FieldAudit.Domain.Question}

Source code is here http://code.google.com/p/sharp-architecture/source/browse/trunk/src/SharpArch/SharpArch.Core/DomainModel/ValidatableObject.cs>

Source code for validation registration: (sorry I’m a new user and can’t post this as a link so you’ll have to copy/paste) whocanhelpme.codeplex.com/SourceControl/changeset/view/58203#883241

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:52:50+00:00Added an answer on May 14, 2026 at 8:52 pm

    The authors of S#arp Architecture and WhoCanHelpMe? (WCHM) both use the Common Service Locator to supply an implementation of SharpArch.Core.CommonValidator.IValidator to their validation classes.

    Where S#arp Architecture uses the following in their SafeServiceLocator<TDependency> class

    
    service = (TDependency)ServiceLocator.Current.GetService(typeof(TDependency));
    

    WCHM uses the following in their ValidatableValueObject class

    
    return ServiceLocator.Current.GetInstance<IValidator>();
    

    The folks that wrote WCHM only stubbed out the GetInstance<IValidator>() method for their unit test

    
                var validator = new Validator();
                provider.Stub(p => p.GetInstance<IValidator>()).Return(validator);
    

    So, if changing to a S#arp Entity from the WCHM ValidatableValueObject its also necessary to stub out the GetService(typeof(IValidator)) that S#arp is going to use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to select an H1 element which is the second-child in its group
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a text area in my form which accepts all possible characters from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.