Example #1
0
        public void Should_Read_Ins_Ion()
        {
            int counter = 0;

            using (var stream = File.OpenRead(FileLoader.GetInsIonPath()))
                using (var reader = IonReaderFactory.Create(stream))
                {
                    while (reader.Read())
                    {
                        if (reader.CurrentSection != "INSURANCE")
                        {
                            continue;
                        }
                        if (reader.IsEmptyLine)
                        {
                            break;
                        }
                        if (reader.IsTableDataRow)
                        {
                            counter++;
                            var columns = reader.CurrentLine.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                            Assert.AreEqual(12, columns.Length);
                            if (counter == 1)
                            {
                                Assert.AreEqual("Berlin Mitte Kronenstraße", columns[0].Trim());
                            }
                            if (counter == 2)
                            {
                                Assert.AreEqual("DANS PARKING AUTOCIT®Õ NIVEAU -2", columns[0].Trim());
                            }
                        }
                    }
                }
            Assert.AreEqual(3, counter);
        }
Example #2
0
        public void Should_Read_Multiple_Sections()
        {
            var counter = 0;

            using (var stream = File.OpenRead(FileLoader.GetInsIonPath()))
                using (var reader = IonReaderFactory.Create(stream))
                {
                    var sectionReader = new GenericSectionReader(reader);
                    sectionReader.OnReadSection += (sender, args) =>
                    {
                        Assert.That(args.SectionName, Is.AnyOf("META", "INSURANCE"));
                        counter++;
                    };
                    sectionReader.Read();
                }
            Assert.AreEqual(2, counter);
        }