Created
October 12, 2012 14:31
-
-
Save markrendle/3879476 to your computer and use it in GitHub Desktop.
Tests for Simple.Data + Impromptu
This file contains 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
[TestFixture] | |
public class CustomerTest | |
{ | |
[Test] | |
public void TestInsert() | |
{ | |
var db = DatabaseFactory.Create(); | |
var customer = db.Customers.Insert(name: "Megadodo", location: "Ursa Minor Beta"); | |
Assert.AreEqual(1, customer.Id); | |
Assert.AreEqual("Megadodo", customer.Name); | |
Assert.AreEqual("Ursa Minor Beta", customer.Location); | |
} | |
[Test] | |
public void TestGet() | |
{ | |
var db = DatabaseFactory.Create(); | |
db.Customers.Insert(name: "Megadodo", location: "Ursa Minor Beta"); | |
var customer = db.Customers.Get(1); | |
Assert.AreEqual(1, customer.Id); | |
Assert.AreEqual("Megadodo", customer.Name); | |
Assert.AreEqual("Ursa Minor Beta", customer.Location); | |
} | |
[Test] | |
public void TestLazyLoadDetail() | |
{ | |
var db = DatabaseFactory.Create(); | |
var customer = db.Customers.Insert(name: "Megadodo", location: "Ursa Minor Beta"); | |
db.Employees.Insert(name: "Ford Prefect", employerId: customer.Id); | |
db.Employees.Insert(name: "Zarniwoop", employerId: customer.Id); | |
customer = db.Customers.Get(customer.Id); | |
Assert.AreEqual(2, customer.Employees.Count); | |
// Make sure we get the same list every time we access the property | |
customer.Employees.RemoveAt(0); | |
Assert.AreEqual(1, customer.Employees.Count); | |
} | |
[Test] | |
public void TestLazyLoadMaster() | |
{ | |
var db = DatabaseFactory.Create(); | |
var customer = db.Customers.Insert(name: "Megadodo", location: "Ursa Minor Beta"); | |
var employee = db.Employees.Insert(name: "Ford Prefect", employerId: customer.Id); | |
Assert.AreEqual("Megadodo", employee.Employer.Name); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment