Rhino.Commons.ActiveRecord
Initialize Active Record, and initialize the container.
If is or string.Empty
a RhinoContainer will not be initialized.
The configuration file to initialize a RhinoContainer
or .
The assemblies to load for NHibernate mapping files.
Initialize Active Record, and initialize the container.
If is or string.Empty
a RhinoContainer will not be initialized.
The configuration file to initialize a RhinoContainer
or .
The configuration to supply to AR
The assemblies to load for NHibernate mapping files.
Initialize NHibernate and builds a session factory
Note, this is a costly call so it will be executed only one.
Creates the in memory db schema using the scope
Starts a and creates the in memory db schema.
Using , , and in your tests.
using NUnit.Framework;
using Rhino.Commons;
using Rhino.Commons.ForTesting;
[TestFixture]
public class FooTest : ActiveRecordEmbeddedDBTestFixtureBase
{
[TestFixtureSetup]
public void TestFixtureSetup()
{
OneTimeInitialize("RhinoContainer.boo", typeof(Foo).Assembly);
}
[Setup]
public void TestSetup()
{
/// Creates a top level UnitOfWork, remember to clean me up
CreateUnitOfWork();
}
[TearDown]
public void TestTearDown()
{
/// Cleanup the top level UnitOfWork
UnitOfWork.Current.Dispose();
}
[Test]
public void CanSaveFoo()
{
Foo f = new Foo();
Foo res = null;
f.Name = "Bar";
Assert.AreEqual(Guid.Empty, f.Id);
With.Transaction(delegate
{
IoC.Resolve<IRepository<Foo>>.Save(f);
});
Assert.AreNotEqual(Guid.Empty, f.Id);
using(UnitOfWork.Start())
res = IoC.Resolve<IRepository<Foo>>.Load(f.Id);
Assert.IsNotNull(res);
Assert.AreEqual("Bar", res.Name);
}
}
Initialize Active Record, and initialize the container.
If is or string.Empty
a RhinoContainer will not be initialized.
The configuration file to initialize a RhinoContainer
or .
The assemblies to load for NHibernate mapping files.
Initialize Active Record, and initialize the container.
If is or string.Empty
a RhinoContainer will not be initialized.
The configuration file to initialize a RhinoContainer
or .
The configuration to supply to AR
The assemblies to load for NHibernate mapping files.
Initialize NHibernate and builds a session factory
Note, this is a costly call so it will be executed only one.
Creates the in memory db schema using the scope
Starts a and creates the in memory db schema.
Using , , and in your tests.
using NUnit.Framework;
using Rhino.Commons;
using Rhino.Commons.ForTesting;
[TestFixture]
public class FooTest : NHibernateInMemoryTest
{
[TestFixtureSetup]
public void TestFixtureSetup()
{
OneTimeInitialize("RhinoContainer.boo", typeof(Foo).Assembly);
}
[Setup]
public void TestSetup()
{
/// Creates a top level UnitOfWork, remember to clean me up
CreateUnitOfWork();
}
[TearDown]
public void TestTearDown()
{
/// Cleanup the top level UnitOfWork
UnitOfWork.Current.Dispose();
}
[Test]
public void CanSaveFoo()
{
Foo f = new Foo();
Foo res = null;
f.Name = "Bar";
Assert.AreEqual(Guid.Empty, f.Id);
With.Transaction(delegate
{
IoC.Resolve<IRepository<Foo>>.Save(f);
});
Assert.AreNotEqual(Guid.Empty, f.Id);
using(UnitOfWork.Start())
res = IoC.Resolve<IRepository<Foo>>.Load(f.Id);
Assert.IsNotNull(res);
Assert.AreEqual("Bar", res.Name);
}
}
Get the entity from the persistance store, or return null
if it doesn't exist.
The entity's id
Either the entity that matches the id, or a null
Load the entity from the persistance store
Will throw an exception if there isn't an entity that matches
the id.
The entity's id
The entity that matches the id
Register the entity for deletion when the unit of work
is completed.
The entity to delete
Registers all entities for deletion when the unit of work
is completed.
Registers all entities for deletion that match the supplied
criteria condition when the unit of work is completed.
criteria condition to select the rows to be deleted
Register te entity for save in the database when the unit of work
is completed.
the entity to save
The saved entity
Saves or update the entity, based on its usaved-value
The saved or updated entity
Saves or update a copy of the entity, based on its usaved-value
Register the entity for update in the database when the unit of work
is completed. (UPDATE)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
2