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()); }
public void Instantiate() { var db = new FakeDB(); var data = new { F = 1, B = 2 }; var key = db.Insert("tbl", data); Assert.NotNull(key); Assert.NotNull(db); }
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 InsertPK() { var db = new FakeDB(); var data = new { Filename = "foosums", Created = DateTime.Now }; var key = db.Insert("Investment.PNImport", data); var fromDb = db.ReadPK("Investment.PNImport", key); Assert.AreEqual(1, fromDb["PNImportId"]); Assert.AreEqual(data._AsDictionary().Assoc("PNImportId", 1).Print(), fromDb.Print()); }
public void ReadTCanSetFieldsFromNullForDictionaryBasedTypes() { var db = new FakeDB(); var row = new Dictionary<string,object>{{"Name", "foosums"}}; db.Insert("test", row); // Previously, the way we did this was to write this as: // obj = db.ReadAll("test").Select(r => new DictBasedTestObject()._SetFrom(r)).Single(); var obj = db.Read<DictBasedTestObject>("test", row).Single(); Assert.NotNull(obj); Assert.False(obj.IsSet); Assert.AreEqual("foosums", obj.Name); }