Skip to content

Instantly share code, notes, and snippets.

@rofr
Created September 17, 2014 03:51
Show Gist options
  • Save rofr/0fde983ec5d167ab4b0e to your computer and use it in GitHub Desktop.
Save rofr/0fde983ec5d167ab4b0e to your computer and use it in GitHub Desktop.
[TestMethod()]
public void can_add_entity()
{
var engine = Engine.LoadOrCreate<MyRelationalModel>();
//Create the entity you want to insert
var category = new Category{ Name = "Beverages"};
//Create a generic command
var addCommand = new AddEntityCommand(category);
//A copy is returned with the the Id assigned
category = engine.Execute(addCommand);
int numEntities = engine.Execute( db => db.SetOf<Category>().Count());
Assert.IsTrue(numEntities == 1);
engine.Close();
}
[TestMethod()]
public void added_entity_was_assigned_a_key()
{
var engine = Engine.LoadOrCreate<MyRelationalModel>();
var category = new Category { Name = "Beverages" };
var addCommand = new AddEntityCommand(category);
category = engine.Execute(addCommand);
Assert.IsTrue(category.Id > 0);
engine.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment