I'm writing some tests for data mapping that takes a ContentItem that has as part of it a UserPart. When I try to use it in my unit tests I and assign the email property I get InfoSet errors. How do I go about mocking up things so that the InfoSet will properly be filled in absent a database?
When attempted using Bertrand's ContentHelpers, as soon as I try to set UserPart's Email property I receive the following:
System.Reflection.TargetException occurred HResult=-2146232829
Message=Non-static method requires a target. Source=mscorlib
StackTrace: at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target) at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index) at Orchard.ContentManagement.InfosetHelper.Store[TPart,TRecord,TProperty](TPart contentPart, Expression`1 targetExpression, TProperty value) in .....Orchard.Source.1.8\src\Orchard\ContentManagement\InfosetHelper.cs:line 122 InnerException:
Example of usage:
ContentItem usrItem = ContentHelpers.PreparePart(new UserPart(), "User") ;
UserPart usrPart = usrItem.As<UserPart>();
usrPart.Email = "[email protected]";
Link to Bertrand's Blog Post showing ContentHelpers: http://weblogs.asp.net/bleroy/faking-orchard-content-items-for-testing