Exemple #1
0
 private static void AssertMissingColumns(ClassMapping mapping, string fieldName, object uninitVal)
 {
     FastDAO<CsvTestObj> dao = new FastDAO<CsvTestObj>(
         new CsvDescriptor(CsvConnectionType.Directory, "..\\..\\Tests\\"), mapping);
     DictionaryDao dictDao = new DictionaryDao(
         new CsvDescriptor(CsvConnectionType.Directory, "..\\..\\Tests\\"), mapping);
     IList<CsvTestObj> objs = dao.Get();
     IList<CheckedDictionary<string, object>> dicts = dictDao.Get();
     Assert.AreEqual(12, objs.Count, "Wrong number of real objects.");
     Assert.AreEqual(12, dicts.Count, "Wrong number of dictionaries.");
     for (int x = 0; x < objs.Count; x++)
     {
         object val;
         switch (fieldName)
         {
             case "One":
                 val = objs[x].One;
                 break;
             case "Two":
                 val = objs[x].Two;
                 break;
             case "Three":
                 val = objs[x].Three;
                 break;
             case "Four":
                 val = objs[x].Four;
                 break;
             case "Five":
                 val = objs[x].Five;
                 break;
             default:
                 throw new ArgumentException("Field " + fieldName + " isn't handled yet.", "fieldName");
         }
         Assert.AreEqual(uninitVal, val, "Field '" + fieldName + "' should be uninitialized because it is unmapped, but isn't.");
         Assert.IsFalse(dicts[x].ContainsKey(fieldName), "Field '" + fieldName + "' should not be in the dictionary because it is unmapped.");
     }
 }