Skip to content

Instantly share code, notes, and snippets.

@dsibinski
Created March 25, 2017 22:22
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 dsibinski/2cefa097384d3c5e33595f37392cc330 to your computer and use it in GitHub Desktop.
Save dsibinski/2cefa097384d3c5e33595f37392cc330 to your computer and use it in GitHub Desktop.
[Test]
public void one_new_person_inserted_adds_one_new_row()
{
// given
var person = new Person()
{
Name = "A",
LastName = "B"
};
var repo = new Repository<Person>(InMemorySqliteConnection);
// when
var numRows = repo.Insert(person).Result;
// then
Assert.AreEqual(1, numRows);
}
[Test]
public void new_person_added_has_id_primarykey_generated()
{
// given
var person1 = new Person
{
Name = "A",
LastName = "B"
};
var person2 = new Person
{
Name = "A",
LastName = "B"
};
var repo = new Repository<Person>(InMemorySqliteConnection);
// when
var n1 = repo.Insert(person1).Result; // getting Result in order to force Task's completion before continuing
var n2 = repo.Insert(person2).Result;
// then
Assert.Greater(person1.Id, 0);
Assert.AreEqual(person2.Id, person1.Id + 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment