Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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