Skip to content

Instantly share code, notes, and snippets.

@stevenharman
Created February 5, 2009 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenharman/58801 to your computer and use it in GitHub Desktop.
Save stevenharman/58801 to your computer and use it in GitHub Desktop.
namespace MyApplication.UnitTests.Core.Persistence
{
[Category("MyApplicationPersistenceModel")]
public class when_using_the_plan_my_night_persistence_model
: Specification, with_auto_persistence_model
{
private MyApplicationPersistenceModel _model;
public override void establish_context()
{
_model = this.configure_model_for<MyApplicationPersistenceModel>();
}
[Test]
public void should_not_map_the_entity_super_type()
{
_model.ShouldNotMap<Entity>();
}
[Test]
public void should_not_map_the_value_object_super_type()
{
_model.ShouldNotMap(typeof(ValueObject<>));
}
[Test]
public void should_map_restaurants()
{
_model.ShouldMap<Restaurant>();
}
[Test]
public void should_not_map_things_that_dont_inherit_from_a_domain_supertype()
{
_model.ShouldNotMap<NonPersistentDomainObject>();
}
}
}
namespace MyApplication.UnitTests.SpecHelpers
{
public interface with_auto_persistence_model
{
}
public static class WithAutoPersistenceModel
{
public static T configure_model_for<T>(this with_auto_persistence_model spec)
where T : AutoPersistenceModel, new()
{
var model = new T();
model.CompileMappings();
return model;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment