Well I was asking how I would mock the code so that it would update
the property correctly. Or is it something that needs to be done in
NHibernate?

On Mar 26, 4:20 pm, Christiaan Baes <[email protected]> wrote:
> I think you should try the nhibernate mailinglist. I don't see what this
> has to do with Rhino mocks.
>
> Nev schreef:
>
> > I have a problem with the saving of objects in the NHibernate session
> > since it does not seem to update the Id column value.
>
> > I have the following mapping:
> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> >                    assembly="Vge.DocumentService.Model"
> >                    namespace="Vge.DocumentService.Model"
> >                    auto-import="false">
> > <class name="Document" table="Document">
> >     <id name="DocumentId" type="Int32" column="DocumentId" unsaved-
> > value="0">
> >       <generator class="identity"></generator>
> >     </id>
> >     <property name="DocumentLookupId" column="DocumentLookupId"
> > type="Int32"></property>
> >     <property name="DocumentTypeId" column="DocumentTypeId"
> > type="Int32"></property>
> >     <property name="Filename" column="Filename" type="String"></
> > property>
> >     <property name="Description" column="Description" type="String"></
> > property>
> >     <many-to-one column="DocumentTypeId" name="DocumentTypeSource"
> > class="DocumentType" />
> >     <many-to-one column="DocumentLookupId" class="DocumentLookup"
> > name="DocumentLookupSource" cascade="save-update" />
> >   </class>
> >   <class name="DocumentLog" table="DocumentLog">
> >     <id name="DocumentLogId" column="DocumentLogId" type="Int32"
> > unsaved-value="0">
> >       <generator class="identity"></generator>
> >     </id>
> >     <property name="DocumentActionId" column="DocumentActionId"
> > type="Int32"></property>
> >     <property name="DocumentId" column="DocumentId" type="Int32"></
> > property>
> >     <property name="Username" column="Username" type="String"></
> > property>
> >     <property name="LogDate" column="LogDate" type="DateTime"></
> > property>
> >   </class>
> > </hibernate-mapping>
>
> > Now I am calling something like the following in my mock:
>
> > var doc = new Document {
> >   DocumentLookupId = 1,
> >   DocumentTypeId = 1,
> >   Filename = "testfile.txt",
> >   Description = "A test file",
> > };
>
> > docRepository.Add(doc);
>
> > var log = new DocumentLog {
> >   DocumentActionId = 1,
> >   DocumentId = doc.DocumentId,
> >   Username = "TestUser",
> >   LogDate = DateTime.Now
> > };
>
> > However I am getting an error that the DocumentId is not allowed to be
> > null in the var log statement. Now the document repository is the Data
> > layer and calls the session so technically after the add is called the
> > session would have been flushed so that the document would have
> > obtained its new id from the DB but there is no way that I know of to
> > mock that so that the documentid is populated in this test. Any input
> > would be appreciated.
>
> > Thanks,
>
> > Nev

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to