Exemplo n.º 1
0
        public void AsyncRead()
        {
            asyncEngine = new FileHelperAsyncEngine(typeof(SampleType));

            SampleType rec1, rec2;

            TestCommon.BeginReadTest(asyncEngine, "Good", "Test1.txt");

            rec1 = (SampleType)asyncEngine.ReadNext();
            Assert.IsNotNull(rec1);
            rec2 = (SampleType)asyncEngine.ReadNext();
            Assert.IsNotNull(rec1);

            Assert.IsTrue(rec1 != rec2);

            rec1 = (SampleType)asyncEngine.ReadNext();
            Assert.IsNotNull(rec2);
            rec1 = (SampleType)asyncEngine.ReadNext();
            Assert.IsNotNull(rec2);

            Assert.IsTrue(rec1 != rec2);

            Assert.AreEqual(0, asyncEngine.ErrorManager.ErrorCount);

            asyncEngine.Close();
        }
Exemplo n.º 2
0
        public void AsyncRead()
        {
            var asyncEngine = new FileHelperAsyncEngine <SampleType>();

            SampleType rec1, rec2;

            Assert.AreEqual(0, asyncEngine.LineNumber);
            TestCommon.BeginReadTest <SampleType>(asyncEngine, "Good", "Test1.txt");

            rec1 = (SampleType)asyncEngine.ReadNext();
            Assert.IsNotNull(rec1);
            Assert.AreEqual(1, asyncEngine.LineNumber);

            rec2 = (SampleType)asyncEngine.ReadNext();
            Assert.IsNotNull(rec1);
            Assert.AreEqual(2, asyncEngine.LineNumber);

            Assert.IsTrue(rec1 != rec2);

            rec1 = (SampleType)asyncEngine.ReadNext();
            Assert.IsNotNull(rec2);
            Assert.AreEqual(3, asyncEngine.LineNumber);
            rec1 = (SampleType)asyncEngine.ReadNext();
            Assert.IsNotNull(rec2);
            Assert.AreEqual(4, asyncEngine.LineNumber);

            Assert.IsTrue(rec1 != rec2);

            Assert.AreEqual(4, asyncEngine.TotalRecords);
            Assert.AreEqual(0, asyncEngine.ErrorManager.ErrorCount);
        }
Exemplo n.º 3
0
        private void RunAsyncTests(string fileName, Encoding enc)
        {
            asyncEngine          = new FileHelperAsyncEngine(typeof(CustomersVerticalBar));
            asyncEngine.Encoding = enc;

            ArrayList arr = new ArrayList();

            TestCommon.BeginReadTest(asyncEngine, fileName);

            while (asyncEngine.ReadNext() != null)
            {
                arr.Add(asyncEngine.LastRecord);
            }

            CustomersVerticalBar[] res = (CustomersVerticalBar[])arr.ToArray(typeof(CustomersVerticalBar));
            Assert.AreEqual(ExpectedRecords, res.Length);
            Assert.AreEqual(ExpectedRecords, engine.TotalRecords);

            Assert.AreEqual("Ana Truñiño Emparedados y helados", res[1].CompanyName);
            Assert.AreEqual("Blondesddsl père et fils", res[6].CompanyName);
            Assert.AreEqual("Frédérique Citeaux", res[6].ContactName);

            Assert.AreEqual("24, place Kléber", res[6].Address);
            Assert.AreEqual("Berguvsvägen  8", res[4].Address);
            Assert.AreEqual("Luleå", res[4].City);
        }
Exemplo n.º 4
0
        public void AsyncReadEnumerableAutoDispose()
        {
            asyncEngine = new FileHelperAsyncEngine(typeof(SampleType));
            TestCommon.BeginReadTest(asyncEngine, "Good", "Test1.txt");

            asyncEngine.ReadNext();
            asyncEngine.ReadNext();

            asyncEngine.Close();
        }
Exemplo n.º 5
0
        public void DiscardFirst6()
        {
            asyncEngine = new FileHelperAsyncEngine(typeof(DiscardType2));

            TestCommon.BeginReadTest(asyncEngine, @"Good\DiscardFirst2.txt");

            Assert.AreEqual("you can get this lines\r\nwith the FileHelperEngine.HeaderText property\r\n", asyncEngine.HeaderText);

            DiscardType2 res = (DiscardType2)asyncEngine.ReadNext();

            Assert.AreEqual(new DateTime(1314, 12, 11), res.Field1);
        }
Exemplo n.º 6
0
        public void AsyncReadEnumerable2()
        {
            using (asyncEngine = new FileHelperAsyncEngine(typeof(SampleType))) {
                TestCommon.BeginReadTest(asyncEngine, "Good", "Test1.txt");
                int lineAnt = asyncEngine.LineNumber;

                foreach (SampleType rec1 in asyncEngine)
                {
                    Assert.IsNotNull(rec1);
                    Assert.AreEqual(lineAnt + 1, asyncEngine.LineNumber);
                    lineAnt = asyncEngine.LineNumber;
                }
            }

            Assert.AreEqual(4, asyncEngine.TotalRecords);
            Assert.AreEqual(0, asyncEngine.ErrorManager.ErrorCount);
            asyncEngine.Close();
        }
Exemplo n.º 7
0
        public void DiscardLast6()
        {
            var asyncEngine = new FileHelperAsyncEngine <DiscardLastType2>();

            TestCommon.BeginReadTest <DiscardLastType2>(asyncEngine, "Good", "DiscardLast2.txt");

            var arr = new ArrayList();

            while (asyncEngine.ReadNext() != null)
            {
                arr.Add(asyncEngine.LastRecord);
            }

            Assert.AreEqual(4, asyncEngine.TotalRecords);

            Assert.AreEqual(expectedLongFooterText, asyncEngine.FooterText);

            Assert.AreEqual(new DateTime(1314, 12, 11), ((DiscardLastType2)arr[0]).Field1);
        }
Exemplo n.º 8
0
        public void DiscardLast6()
        {
            asyncEngine = new FileHelperAsyncEngine(typeof(DiscardLastType2));

            TestCommon.BeginReadTest(asyncEngine, @"Good\DiscardLast2.txt");

            ArrayList arr = new ArrayList();

            while (asyncEngine.ReadNext() != null)
            {
                arr.Add(asyncEngine.LastRecord);
            }

            Assert.AreEqual(4, asyncEngine.TotalRecords);

            Assert.AreEqual("you can get this lines\r\nwith the FileHelperEngine.FooterText property\r\n", asyncEngine.FooterText);

            Assert.AreEqual(new DateTime(1314, 12, 11), ((DiscardLastType2)arr[0]).Field1);
        }
Exemplo n.º 9
0
        public void AsyncRead2()
        {
            SampleType rec1;

            asyncEngine = new FileHelperAsyncEngine(typeof(SampleType));

            TestCommon.BeginReadTest(asyncEngine, @"Good\test1.txt");
            int lineAnt = asyncEngine.LineNumber;

            while (asyncEngine.ReadNext() != null)
            {
                rec1 = (SampleType)asyncEngine.LastRecord;
                Assert.IsNotNull(rec1);
                Assert.AreEqual(lineAnt + 1, asyncEngine.LineNumber);
                lineAnt = asyncEngine.LineNumber;
            }

            Assert.AreEqual(4, asyncEngine.TotalRecords);
            Assert.AreEqual(0, asyncEngine.ErrorManager.ErrorCount);
        }
Exemplo n.º 10
0
        private void CoreRunAsync(params string[] pathElements)
        {
            ArrayList arr = new ArrayList();

            TestCommon.BeginReadTest(asyncEngine, pathElements);

            foreach (object record in asyncEngine)
            {
                arr.Add(record);
            }

            CustomersVerticalBar[] res = (CustomersVerticalBar[])arr.ToArray(typeof(CustomersVerticalBar));
            ExpectedRecords.AssertEqualTo <int>(res.Length, "Length is not equal");
            ExpectedRecords.AssertEqualTo <int>(asyncEngine.TotalRecords, "Total number of records not equal");

            expectedTextWithNTilde.AssertEqualTo <String>(res[1].CompanyName);
            expectedTextWithEGrave.AssertEqualTo <String>(res[6].CompanyName);
            expectedTextWithEAcute1.AssertEqualTo <String>(res[6].ContactName);

            expectedTextWithEAcute2.AssertEqualTo <String>(res[6].Address);
            expectedTextWithADiaeresis.AssertEqualTo <String>(res[4].Address);
            expectedTextWithARing.AssertEqualTo <String>(res[4].City);
        }
Exemplo n.º 11
0
        private void CoreRunAsync(params string[] pathElements)
        {
            var arr = new ArrayList();

            TestCommon.BeginReadTest(asyncEngine, pathElements);

            foreach (object record in asyncEngine)
            {
                arr.Add(record);
            }

            var res = (CustomersVerticalBar[])arr.ToArray(typeof(CustomersVerticalBar));

            Check.That(ExpectedRecords).IsEqualTo(res.Length);
            Check.That(ExpectedRecords).IsEqualTo(asyncEngine.TotalRecords);

            Check.That(expectedTextWithNTilde).IsEqualTo(res[1].CompanyName);
            Check.That(expectedTextWithEGrave).IsEqualTo(res[6].CompanyName);
            Check.That(expectedTextWithEAcute1).IsEqualTo(res[6].ContactName);

            Check.That(expectedTextWithEAcute2).IsEqualTo(res[6].Address);
            Check.That(expectedTextWithADiaeresis).IsEqualTo(res[4].Address);
            Check.That(expectedTextWithARing).IsEqualTo(res[4].City);
        }