chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
Hello,
I may be doing something wrong, but am having issues getting recordmanager to work for a derived class. I have very similar code for non derived types and everything works as I would expect it to - this is the only instance where I have run across this error. Any help would be greatly appreciated. Any suggestions on how to mock nhibernate v3 chained queries without needing to use the recorder manager would be even better! :D

Setup
using (RecordExpectations rec = RecorderManager.StartRecording())
{
 session.QueryOver<BuyerSecurityProfile>().Where(x => x.EmailAddress == emailAddress).SingleOrDefault();
// buyerSecurityProfile faked above using Typemock
rec.Return(buyerSecurityProfile);
}

Erroring Code

 var address = _session.QueryOver<BuyerSecurityProfile>().Where(x => x.EmailAddress == emailAddress).SingleOrDefault();

Error message
System.ArgumentException : Field 'Myapp.Controllers.Buyers.AccountController+<>c__DisplayClass21.emailAddress' is not defined for type 'System.Object'

Data Classes

    
public class SecurityProfile
{
        public virtual string UserName { get; set; }
        public virtual string ApplicationName { get; set; }
        public virtual string EmailAddress { get; set; }
   ...
}


public class BuyerSecurityProfile : SecurityProfile
{
     public virtual DateTime LastLoggedInToBuyerPortal { get; set; }
     public virtual Buyer Buyer { get; set; }
}


Thanks in advance!
asked by jirwin (1.7k points)

1 Answer

0 votes
Hi Jason,

RecorderManager is from our second generation API.
You can use the latest API ( which is more straightforward and intuitive ) to replace the recording block with:
Isolate.Fake.Instance<BuyerSecurityProfile>();

Find more info on the 3rd generation API here.
Please let me know if it helps.
answered by alex (17k points)
...