Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created December 15, 2010 17:36
Show Gist options
  • Save jfromaniello/742314 to your computer and use it in GitHub Desktop.
Save jfromaniello/742314 to your computer and use it in GitHub Desktop.
using System.Linq;
using BCS.Domain.Entities;
using NUnit.Framework;
namespace BCS.DAO.NHibernate.Tests
{
[TestFixture]
public class NationalitiesDaoTests
{
[Test]
public void CanInsertNationatlity()
{
var nationalityDao = new Dao<NATIONALITY>(FixtureContext.Sessions);
var nationality = new NATIONALITY
{
NATIONALITY_CODE = "BE",
DESCRIPTION = "Belgica"
};
FixtureContext.ExecuteInSessionContext(() => nationalityDao.Insert());
//ASSERT
Nationality readed;
FixtureContext.ExecuteInSessionContext(() => readed = nationalityDao.Get(nationality.ID));
readed.Satisfy(n => n.NATIONALITY_CODE == "BE" && n.DESCRIPTION == "Belgica");
}
[TearDown]
public void CleanUp()
{
var nationalityDao = new Dao<NATIONALITY>(FixtureContext.Sessions);
FixtureContext.ExecuteInSessionContext(()=>
{
var nationality = nationalityDao.GetAll(n => n.NATIONALITY_CODE == "BE").FirstOrDefault();
if(nationality != null) nationalityDao.Delete(nationality);
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment