示例#1
0
        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");
            }
        }
示例#2
0
        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");

                }
        }