Hi Ken,

In answer to your questions.

a.  I'm new-ing the helper as I need an instance of it within the
ViewComponent. I see that the CaptchaComponent from the Castle Contrib
project does the same thing.
http://svn.castleproject.org:8080/svn/castlecontrib/viewcomponents/trunk/Castle.MonoRail.ViewComponents/CaptchaComponent.cs.
Am I doing this completely wrong?

b. I don't have a propertybag at all in the test environment as I'm
currently try to test a "New" action.  Likewise in my Controller I
don't have a PropertyBag value for the New action.  The strange thing
is that the ViewComponent works fine when not in the test environment.

To try and make it a bit clearer what I'm trying to do please look at
the viewcomponent

http://membranecms.googlecode.com/svn/trunk/Membrane/ViewComponents/AutomaticFormFieldGeneratorComponent.cs

and it's test

http://membranecms.googlecode.com/svn/trunk/Membrane.Tests/Unit/Web/MonoRail/ViewComponents/AutomaticFormGeneratorComponentFixture.cs

Please be gentle as this is the first time I've tried to TDD a
ViewComponent :-)

Thanks

John

On Apr 8, 10:41 am, Ken Egozi <egoz...@gmail.com> wrote:
> a. why are you new-ing the helper? they are all being created anyway by the
> framework.
> b. it appear that the failing call is ObtainRootInstance, with the target Id
> you supply to the TextField method.
> is there something in the PropertyBag that corresponds to fieldId in the
> test environment?
>
> On Wed, Apr 8, 2009 at 12:36 PM, johnpoll...@googlemail.com <
>
>
>
> johnpoll...@googlemail.com> wrote:
>
> > I'm currently working on a ViewComponent however I'm struggling the
> > testing side of things.
>
> > The ViewComponent uses the FormHelper within it.
>
> > formHelper = new FormHelper(EngineContext);
>
> > and is creating a series of TextFields dynamically
>
> > formHelper.TextField(fieldId)
>
> > This works fine when running the view.  However when running the test
> > which inherits from BaseViewComponentTest I'm getting the following
> > error message when the formHelper.TextField(fieldId) code is run.
>
> > System.NullReferenceException: Object reference not set to an instance
> > of an object.
> > at
>
> > Castle.MonoRail.Framework.Helpers.AbstractFormRelatedHelper.ObtainRootInstance
> > (RequestContext context, String target)
> > at
>
> > Castle.MonoRail.Framework.Helpers.AbstractFormRelatedHelper.ObtainRootInstance
> > (RequestContext context, String target, String[]& pieces)
> > at
> > Castle.MonoRail.Framework.Helpers.AbstractFormRelatedHelper.ObtainValue
> > (RequestContext context, String target)
> > at
> > Castle.MonoRail.Framework.Helpers.AbstractFormRelatedHelper.ObtainValue
> > (String target)
> > at
> > Castle.MonoRail.Framework.Helpers.AbstractFormRelatedHelper.ObtainValue
> > (String target, IDictionary attributes)
> > at Castle.MonoRail.Framework.Helpers.FormHelper.TextField(String
> > target, IDictionary attributes)
> > at Castle.MonoRail.Framework.Helpers.FormHelper.TextField(String
> > target)
>
> > Is there something I'm missing?  I've seen this discussion about the
> > lack of PropertyBaghttp://markmail.org/message/xremym6hthsudx4obut
> > as I said the same code works fine when running the viewcomponent in
> > the view.
>
> > Hope this makes sense
>
> > John
>
> --
> Ken 
> Egozi.http://www.kenegozi.com/bloghttp://www.delver.comhttp://www.musicglue.comhttp://www.castleproject.orghttp://www.gotfriends.co.il
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to castle-project-users@googlegroups.com
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to