public void TestRead_MultipleCallsToValues_ReturnsSameValues()
        {
            string text = "a,b,c";
            SeparatedValueParser parser = new SeparatedValueParser(new MemoryStream(Encoding.Default.GetBytes(text)));
            bool canRead = parser.Read();

            Assert.IsTrue(canRead, "Could not read the record.");
            string[] expected = new string[] { "a", "b", "c" };
            object[] actual   = parser.GetValues();
            CollectionAssert.AreEqual(expected, actual, "The wrong values were parsed.");
            actual = parser.GetValues();
            CollectionAssert.AreEqual(expected, actual, "The same values were not returned multiple times.");
        }
        public void TestRead_GetValuesWithoutReading_Throws()
        {
            string text = "a,b,c";
            SeparatedValueParser parser = new SeparatedValueParser(new MemoryStream(Encoding.Default.GetBytes(text)));

            parser.GetValues();
        }
        public void TestRead_ValuesAfterEndOfFile_Throws()
        {
            string text = "a,b,c";
            SeparatedValueParser parser = new SeparatedValueParser(new MemoryStream(Encoding.Default.GetBytes(text)));
            bool canRead = parser.Read();

            Assert.IsTrue(canRead, "Could not read the record.");
            canRead = parser.Read();
            Assert.IsFalse(canRead, "We should have reached the end of the file.");
            parser.GetValues();
        }
        public void TestRead_SingleRecord_ReturnsTrueOnce()
        {
            const string         text   = "a,b,c";
            SeparatedValueParser parser = new SeparatedValueParser(new MemoryStream(Encoding.Default.GetBytes(text)));
            bool canRead = parser.Read();

            Assert.IsTrue(canRead, "Could not read the record.");
            string[] expected = new string[] { "a", "b", "c" };
            object[] actual   = parser.GetValues();
            CollectionAssert.AreEqual(expected, actual, "The wrong values were parsed.");
            canRead = parser.Read();
            Assert.IsFalse(canRead, "No more records should have been read.");
        }
        public void TestGetSchema_SchemaProvided_ParsesValues()
        {
            const string text   = @"123,Bob,1/19/2013";
            Schema       schema = new Schema();

            schema.AddColumn(new Int32Column("id"))
            .AddColumn(new StringColumn("name"))
            .AddColumn(new DateTimeColumn("created"));
            SeparatedValueParser parser = new SeparatedValueParser(new MemoryStream(Encoding.Default.GetBytes(text)), schema);

            Assert.IsTrue(parser.Read(), "The first record was skipped.");
            object[] actual   = parser.GetValues();
            object[] expected = new object[] { 123, "Bob", new DateTime(2013, 1, 19) };
            CollectionAssert.AreEqual(expected, actual, "The values were not parsed as expected.");
        }
 public void TestRead_ValuesAfterEndOfFile_Throws()
 {
     string text = "a,b,c";
     SeparatedValueParser parser = new SeparatedValueParser(new MemoryStream(Encoding.Default.GetBytes(text)));
     bool canRead = parser.Read();
     Assert.IsTrue(canRead, "Could not read the record.");
     canRead = parser.Read();
     Assert.IsFalse(canRead, "We should have reached the end of the file.");
     parser.GetValues();
 }
 public void TestRead_SingleRecord_ReturnsTrueOnce()
 {
     const string text = "a,b,c";
     SeparatedValueParser parser = new SeparatedValueParser(new MemoryStream(Encoding.Default.GetBytes(text)));
     bool canRead = parser.Read();
     Assert.IsTrue(canRead, "Could not read the record.");
     string[] expected = new string[] { "a", "b", "c" };
     object[] actual = parser.GetValues();
     CollectionAssert.AreEqual(expected, actual, "The wrong values were parsed.");
     canRead = parser.Read();
     Assert.IsFalse(canRead, "No more records should have been read.");
 }
 public void TestRead_MultipleCallsToValues_ReturnsSameValues()
 {
     string text = "a,b,c";
     SeparatedValueParser parser = new SeparatedValueParser(new MemoryStream(Encoding.Default.GetBytes(text)));
     bool canRead = parser.Read();
     Assert.IsTrue(canRead, "Could not read the record.");
     string[] expected = new string[] { "a", "b", "c" };
     object[] actual = parser.GetValues();
     CollectionAssert.AreEqual(expected, actual, "The wrong values were parsed.");
     actual = parser.GetValues();
     CollectionAssert.AreEqual(expected, actual, "The same values were not returned multiple times.");
 }
 public void TestRead_GetValuesWithoutReading_Throws()
 {
     string text = "a,b,c";
     SeparatedValueParser parser = new SeparatedValueParser(new MemoryStream(Encoding.Default.GetBytes(text)));
     parser.GetValues();
 }
 public void TestGetSchema_SchemaProvided_ParsesValues()
 {
     const string text = @"123,Bob,1/19/2013";
     Schema schema = new Schema();
     schema.AddColumn(new Int32Column("id"))
           .AddColumn(new StringColumn("name"))
           .AddColumn(new DateTimeColumn("created"));
     SeparatedValueParser parser = new SeparatedValueParser(new MemoryStream(Encoding.Default.GetBytes(text)), schema);
     Assert.IsTrue(parser.Read(), "The first record was skipped.");
     object[] actual = parser.GetValues();
     object[] expected = new object[] { 123, "Bob", new DateTime(2013, 1, 19) };
     CollectionAssert.AreEqual(expected, actual, "The values were not parsed as expected.");
 }