Exemplo n.º 1
0
        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.");
        }
Exemplo n.º 2
0
        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]);
        }
Exemplo n.º 3
0
        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.");
        }
Exemplo n.º 4
0
        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.");
        }
Exemplo n.º 5
0
        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 ");
        }
Exemplo n.º 6
0
        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.");
        }
Exemplo n.º 7
0
        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.");
        }
Exemplo n.º 8
0
        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.");
        }