public void WriteNoData() { dbf = new Dbf(DbfVersion.VisualFoxPro); dbf.SaveTo("test.dbf"); byte[] data = ReadBytes(); Assert.AreEqual(0x30, data[0], "Version should be 0x30."); }
public void WriteOneField() { dbf = new Dbf(DbfVersion.VisualFoxPro); dbf.AddNewField("TEST", DbfFieldType.Character, 12); dbf.SaveTo("test.dbf"); dbf = new Dbf("test.dbf"); Assert.AreEqual("TEST", dbf.Fields[0].Name, "Field name should be TEST."); }
public void DemoCode() { var dbf = new Dbf(DbfVersion.FoxPro2WithMemo); DbfField testField = dbf.AddNewField("TEST", DbfFieldType.Character, 12); DbfRecord record = dbf.CreateRecord(); record[testField] = "HELLO"; dbf.SaveTo("test.dbf"); Assert.AreEqual(record.Data[0], record[testField]); }
public void NumericField() { dbf = new Dbf(DbfVersion.VisualFoxPro); dbf.AddNewField("TEST", DbfFieldType.Numeric, 12); DbfRecord record = new DbfRecord(dbf.Fields); dbf.Records.Add(record); record.Data[0] = 3.14; dbf.SaveTo("test.dbf"); dbf = new Dbf("test.dbf"); Assert.AreEqual(3.14M, dbf.Records[0][0], "Record content should be 3.14."); }
public void WriteFieldAndRecord() { dbf = new Dbf(DbfVersion.VisualFoxPro); dbf.AddNewField("TEST", DbfFieldType.Character, 12); DbfRecord record = new DbfRecord(dbf.Fields); dbf.Records.Add(record); record.Data[0] = "HELLO"; dbf.SaveTo("test.dbf"); dbf = new Dbf("test.dbf"); Assert.AreEqual("HELLO", dbf.Records[0][0], "Record content should be HELLO."); }
public void CurrencyField() { dbf = new Dbf(DbfVersion.VisualFoxPro); dbf.AddNewField("TEST", DbfFieldType.Currency, 8); DbfRecord record = new DbfRecord(dbf.Fields); dbf.Records.Add(record); record.Data[0] = 138799L; dbf.SaveTo("test.dbf"); dbf = new Dbf("test.dbf"); Assert.AreEqual(138799L, dbf.Records[0][0], "Record content should be "); }
public void IntegerField() { dbf = new Dbf(DbfVersion.VisualFoxPro); dbf.AddNewField("TEST", DbfFieldType.Integer, 4); DbfRecord record = new DbfRecord(dbf.Fields); dbf.Records.Add(record); record.Data[0] = 34; dbf.SaveTo("test.dbf"); dbf = new Dbf("test.dbf"); Assert.AreEqual(34, dbf.Records[0][0], "Record content should be 34."); }
public void DateTimeField() { dbf = new Dbf(DbfVersion.VisualFoxPro); dbf.AddNewField("TEST", DbfFieldType.DateTime, 8); DbfRecord record = new DbfRecord(dbf.Fields); dbf.Records.Add(record); record.Data[0] = new DateTime(2018, 8, 7, 20, 15, 8); dbf.SaveTo("test.dbf"); dbf = new Dbf("test.dbf"); Assert.AreEqual(new DateTime(2018, 8, 7, 20, 15, 8), dbf.Records[0][0], "Record content should be 2018-08-07 20:15:08."); }
public void LogicalField() { dbf = new Dbf(DbfVersion.VisualFoxPro); dbf.AddNewField("TEST", DbfFieldType.Logical, 12); DbfRecord record = new DbfRecord(dbf.Fields); dbf.Records.Add(record); record.Data[0] = true; dbf.SaveTo("test.dbf"); dbf = new Dbf("test.dbf"); Assert.AreEqual(true, dbf.Records[0][0], "Record content should be TRUE."); }