Example #1
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);
        }
Example #2
0
 public void ReadFromNewTable()
 {
     var db = new FakeDB();
     Assert.AreEqual("()", db.Read("foosums", new { a = "b" }).Print());
 }
Example #3
0
        public void TreatsNullsAndDbNullsTheSame()
        {
            var db = new FakeDB();
            var rows = new object[]{
                new { Age = DBNull.Value },
                new Person() { Age = null }
            };

            var ids = rows.Select(r => db.InsertAutoKey("Person", r)).ToList();

            var fromDb = db.Read("Person", new { Age = DBNull.Value });
            Assert.AreEqual(2, fromDb.Count());
            Assert.AreEqual(fromDb.First()["Age"], fromDb.Second()["Age"]);
        }