public void NameFirstColumnByNumber() { string name; using (var dbf = DbfReader.Open(PathToDbf)) { name = dbf.GetColumns[0].Name; } Assert.AreEqual(name, FirstColumn); }
public void WriteHeadOnly() { int count; var item = new List <KLF_NAMESDBF>(); DbfWriter.Save(Tmp, item); using (var dbf = DbfReader.Open(Tmp)) { count = dbf.Count; } Assert.AreEqual(0, count); }
public void ReadToDataTable() { var dt = new DataTable(); int columns; using (var dbf = DbfReader.Open(PathToDbf)) { columns = dbf.GetColumns.Count; #pragma warning disable 612,618 dbf.Fill(dt); #pragma warning restore 612,618 } Assert.AreEqual(columns, dt.Columns.Count, "Колонок"); Assert.AreEqual(Count, dt.Rows.Count, "Строк"); }
public void CountRecordByRead() { var items = 0; using (var dbf = DbfReader.Open(PathToDbf)) { #pragma warning disable 612,618 while (dbf.Read()) #pragma warning restore 612,618 { items++; } } Assert.AreEqual(Count, items, "Количество записей"); }
public void NumberOfColumnByName() { var index = -1; using (var dbf = DbfReader.Open(PathToDbf)) { for (var i = 0; i < dbf.GetColumns.Count; i++) { if (dbf.GetColumns[i].Name == FirstColumn) { index = i; } } } Assert.AreEqual(index, 0); }
static void Main(string[] args) { if (args.Length != 2) { throw new Exception("Следует запускать в виде: ClassGenerator.exe pathtodbf pathtoclass"); } var pathtodbf = args[0]; if (!File.Exists(pathtodbf)) { throw new FileNotFoundException(pathtodbf); } var pathtoclass = args[1]; using (var dbf = DbfReader.Open(pathtodbf)) { var filename = Path.GetFileNameWithoutExtension(pathtodbf); GenerateClass(dbf.GetColumns, filename, pathtoclass); } Console.WriteLine("Final"); Console.ReadLine(); }
public void WriteNRecords() { var rand = new Random(); var n = rand.Next(Int16.MaxValue); var list = new List <KLF_NAMESDBF>(Enumerable.Repeat(new KLF_NAMESDBF { FULL_NAME = "1", DATEF = DateTime.Now, DATEEmpty = DateTime.MinValue, TimeEmpty = DateTime.MinValue, TimeFull = DateTime.Now, Bool = false, Dec = 0m }, n)); DbfWriter.Save(Tmp, list); int readN; using (var dbf = DbfReader.Open(Tmp)) { readN = dbf.Count; } Assert.AreEqual(n, readN); }