Created
September 17, 2014 03:51
-
-
Save rofr/0fde983ec5d167ab4b0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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