running a simple test with NUnit and FluentAssertion i have this messagge for failure:
Expected object to be
Gedi.Domain.Object.Entity.Persona
{
Annullato = False
Descrizione = "Persona1"
Id = 1
}, but found
Gedi.Domain.Object.Entity.Persona
{
Annullato = False
Descrizione = "Persona1"
Id = 1
}.
but I do not see differences. which may be the cause of failure?
this is the test method
public void CanSaveAndLoadDocumento()
{
//Arrange
Documento documentoTarget = new Documento();
Documento documentoActual;
documentoTarget.Id = fixture.Create<int>();
// Act
using (IUnitOfWork uow = new UnitOfWork())
{
uow.Start();
documentoTarget.Persona = uow.ServiceRepositoryFor<Persona>().GetById(1);
uow.DocumentoRepository.Create(documentoTarget);
uow.Commit();
uow.CloseConnection();
uow.Start();
documentoActual = uow.DocumentoRepository.GetById(documentoTarget.Id);
uow.CloseConnection();
}
//Assert
documentoActual.Persona.Should().Be(documentoTarget.Persona);
}
Persona with ID = 1 is handwritten by me directly in database
this is the base repository i use with NHibernate
public abstract class RepositoryBase<TEntity, TKey> : IDisposable
where TEntity : class, IKeyedEntity<TKey>
where TKey : struct
{
protected ISession _session;
public RepositoryBase(ISession session)
{
_session = session;
}
public void Create(TEntity entity)
{
_session.SaveOrUpdate(entity);
}
public TEntity GetById(TKey id)
{
return _session.Get<TEntity>(id);
}
}
public class DocumentoRepository : RepositoryBase<Documento, int>
{
public DocumentoRepository(ISession session)
: base(session)
{
}
}