public void Ensure() { var db = new FakeDB(); var data = new { MyTableId = 1, Foo = "bar"}; // This should do an insert db.Ensure("MyTable", data); Assert.AreEqual("(([Foo,bar],[MyTableId,1]))", db.Table("MyTable").Print()); var newData = new { MyTableId = 1, Foo = "sums" }; // This should do an update db.Ensure("MyTable", newData); Assert.AreEqual("(([Foo,sums],[MyTableId,1]))", db.Table("MyTable").Print()); }
public void IncrementsPKs() { var db = new FakeDB(); var data = new { Z = "A" }; 2.Times(() => db.Insert("Foosums", data)); Assert.AreEqual("(([FoosumsId,1],[Z,A]),([FoosumsId,2],[Z,A]))", db.Table("Foosums").Print()); }
public void DoesntRepeatAutoKeys() { var db = new FakeDB(); var data = new { Z = "A" }; 2.Times(() => db.Insert("P", data)); db.Delete("P", new { PId = 2 }); db.Insert("P", new {Z = "B"}); Assert.AreEqual("(([PId,1],[Z,A]),([PId,3],[Z,B]))", db.Table("P").Print()); }
public void UpdateWorks() { var db = new FakeDB(); var data = new { Z = "A" }; db.Insert("Foosums", data); var keys = db.Insert("Foosums", data); // Now, we'll update the second row, and the first should remain unchanged db.Update("Foosums", keys.Assoc("Z", "B")); Assert.AreEqual("(([FoosumsId,1],[Z,A]),([FoosumsId,2],[Z,B]))", db.Table("Foosums").Print()); }