Пример #1
0
        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());
        }
Пример #2
0
        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());
        }
Пример #3
0
 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);
 }
Пример #4
0
        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());
        }
Пример #5
0
        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());
        }
Пример #6
0
        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);
        }