public void checkAnnoymous()
        {
            var fieldLength = 2400;
            string writtenValue;
            using (
                Stream fos =
                    File.Open(TestSelectPath,
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                var writer = new DBFWriter
                {
                    DataMemoLoc = Path.ChangeExtension(TestSelectPath, "DBT")
                };
                var field = new DBFField("F1", NativeDbType.Memo);
                var field2 = new DBFField("F2", NativeDbType.Numeric, 10);
                var field3 = new DBFField("F3", NativeDbType.Char, 10);
                writer.Fields = new[] { field, field2, field3 };

                writtenValue = "alpha";
                writer.AddRecord(new MemoValue(GetCharacters(fieldLength)), 10, writtenValue);
                writer.Write(fos);
            }
            using (
                Stream fis =
                    File.Open(TestSelectPath,
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                var reader = new DBFReader(fis)
                {
                    DataMemoLoc = Path.ChangeExtension(TestSelectPath, "DBT")
                };

                var readValues = reader.AllRecords(new {F2 = default(decimal), F3 = default(string)});

                Assert.That(readValues.First().F3, StartsWith(writtenValue), "Written Value not equaling Read");
            }
        }
        public void checkDataType_M()
        {
            var fieldLength = 2400;
            MemoValue writtenValue;
            using (
                Stream fos =
                    File.Open(TestMemoPath,
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                var writer = new DBFWriter
                                 {
                                     DataMemoLoc = Path.ChangeExtension(TestMemoPath, "DBT")
                                 };
                var field = new DBFField("F1", NativeDbType.Memo);
                writer.Fields = new[] { field };

                writtenValue = new MemoValue(GetCharacters(fieldLength));
                writer.AddRecord(writtenValue);
                writer.Write(fos);
            }
            using (
                Stream fis =
                    File.Open(TestMemoPath,
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                var reader = new DBFReader(fis)
                {
                    DataMemoLoc = Path.ChangeExtension(TestMemoPath, "DBT")
                };
                var readValues = reader.NextRecord();

                Assert.That(readValues[0], EqualTo(writtenValue), "Written Value not equaling Read");
            }
        }
 public void WriteSample()
 {
     var field = new DBFField {Name = "F1", DataType = NativeDbType.Numeric};
     var writer = new DBFWriter {Fields = new[] {field}};
     writer.AddRecord(3);
     using (
         Stream fos =
             File.Open(TestPath,
                       FileMode.OpenOrCreate,
                       FileAccess.ReadWrite))
     {
         writer.Write(fos);
     }
 }
        public void checkSelectDynamic()
        {
            var fieldLength = 2400;
            string writtenValue;
            string writtenMemo;
            using (
                Stream fos =
                    File.Open(TestSelectPath,
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                var writer = new DBFWriter
                {
                    DataMemoLoc = Path.ChangeExtension(TestSelectPath, "DBT")
                };
                var field = new DBFField("F1", NativeDbType.Memo);
                var field2 = new DBFField("F2", NativeDbType.Numeric, 10);
                var field3 = new DBFField("F3", NativeDbType.Char, 10);
                writer.Fields = new[] { field, field2, field3 };

                writtenValue = "alpha";
                writtenMemo = GetCharacters(fieldLength);
                writer.AddRecord(new MemoValue(writtenMemo), 10, writtenValue);
                writer.Write(fos);
            }
            using (
                Stream fis =
                    File.Open(TestSelectPath,
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                var reader = new DBFReader(fis)
                {
                    DataMemoLoc = Path.ChangeExtension(TestSelectPath, "DBT")
                };
                reader.SetSelectFields("F1","F3");
                var readValues = reader.DynamicAllRecords().First();

                Assert.That(readValues.F1.ToString(), EqualTo(writtenMemo), "Written Value not equaling Read");
                Assert.That(readValues.F3, EqualTo(writtenValue), "Written Value not equaling Read");
            }
        }
        public void checkLongCharLengthWithClipper()
        {
            var fieldLength = 750;
            string writtenValue;
            using (
                Stream fos =
                    File.Open(TestClipLongPath,
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                var writer = new DBFWriter();
                var field = new DBFField("F1", NativeDbType.Char, fieldLength);
                writer.Fields = new[] { field };

                writtenValue = GetCharacters(fieldLength);
                writer.AddRecord(writtenValue);
                writer.Write(fos);
            }
            using (
                Stream fis =
                    File.Open(TestClipLongPath,
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                var reader = new DBFReader(fis);
                Assert.That(reader.Fields.First().FieldLength, EqualTo(fieldLength));
                var readValues = reader.NextRecord();

                Assert.That(readValues[0], EqualTo(writtenValue), "Written Value not equaling Read");
            }
        }
        public void checkDynamicProxyWhere()
        {
            var fieldLength = 2400;
            string writtenValue;
            using (
                Stream fos =
                    File.Open(TestSelectPath,
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                var writer = new DBFWriter
                {
                    DataMemoLoc = Path.ChangeExtension(TestSelectPath, "DBT")
                };
                var field = new DBFField("F1", NativeDbType.Memo);
                var field2 = new DBFField("F2", NativeDbType.Numeric, 10);
                var field3 = new DBFField("F3", NativeDbType.Char, 10);
                writer.Fields = new[] { field, field2, field3 };

                writtenValue = "alpha";
                writer.AddRecord(new MemoValue(GetCharacters(fieldLength)), 10, writtenValue);

                writer.AddRecord(new MemoValue(GetCharacters(fieldLength)), 12, "beta");

                writer.Write(fos);
            }

                using(var reader = new DBFReader(TestSelectPath){
                    DataMemoLoc = Path.ChangeExtension(TestSelectPath, "DBT")})
                {

                    var readValues = reader.DynamicAllRecords();

                    Assert.That(Equals(readValues.Count(), 2), "All Records not matching");

                }

                using (var reader = new DBFReader(TestSelectPath)
                {
                    DataMemoLoc = Path.ChangeExtension(TestSelectPath, "DBT")})
                {

                    var readValues = reader.DynamicAllRecords(whereColumn: "F2", whereColumnEquals: 10);

                    Assert.That(Equals(readValues.Count(), 1), "All Records not matching");

                }

                using (var reader = new DBFReader(TestSelectPath)
                {
                    DataMemoLoc = Path.ChangeExtension(TestSelectPath, "DBT")})
                {

                    var readValues = reader.DynamicAllRecords(whereColumn: "F2", whereColumnEquals: 12);

                    Assert.That(Equals(readValues.Count(), 1), "All Records not matching");

                }
                using (var reader = new DBFReader(TestSelectPath)
                {
                    DataMemoLoc = Path.ChangeExtension(TestSelectPath, "DBT")})
                {

                    var readValues = reader.DynamicAllRecords(whereColumn: "F2", whereColumnEquals: 13);

                    Assert.That(Equals(readValues.Count(), 0), "All Records not matching");

                }
        }
        public void checkDataType_N()
        {
            Decimal writtenValue;
            using (
                Stream fos =
                    File.Open(TestPath,
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                var writer = new DBFWriter();
                var field = new DBFField("F1", NativeDbType.Numeric, 15, 0);
                writer.Fields = new[] { field };

                writtenValue = 123456789012345L;
                writer.AddRecord(writtenValue);
                writer.Write(fos);
            }
            using (
                Stream fis =
                    File.Open(TestPath,
                              FileMode.OpenOrCreate,
                              FileAccess.ReadWrite))
            {
                var reader = new DBFReader(fis);

                var readValues = reader.NextRecord();

                Assert.That(readValues[0], EqualTo(writtenValue),"Written Value Equals Read");
            }
        }