public void HeaderRowParserSetsImportDefinitionHeaderRowToTrue()
        {
            // Arrange
            var id = new ImportDefinition();

            // Act
            HeaderRowParser.Parse("HEADERROW", id);

            // Assert
            Assert.IsTrue(id.HeaderRow);
        }
 public void HeaderRowParserThrowsExceptionWhenImportDefinitionIsNull()
 {
     // Act
     try
     {
         HeaderRowParser.Parse("HEADERROW", null);
         Assert.Fail("ArgumentNullException expected, not thrown.");
     }
     catch (ArgumentNullException ex)
     {
         Assert.AreEqual("ID", ex.ParamName);
     }
     catch (Exception ex)
     {
         Assert.Fail("ArgumentNullException expected, " +
                     ex.GetType().Name +
                     " thrown instead.");
     }
 }
Ejemplo n.º 3
0
 private static void ParseLine(string line, ImportDefinition id)
 {
     if (line.StartsWith("#"))
     {
         // This is a comment
         return;
     }
     if (line.StartsWith("COLUMN"))
     {
         ColumnDefinitionParser.Parse(line, id);
         return;
     }
     if (line.StartsWith("FILETYPE"))
     {
         FileTypeParser.Parse(line, id);
         return;
     }
     else if (line.StartsWith("HEADERROW"))
     {
         HeaderRowParser.Parse(line, id);
         return;
     }
     else if (line.StartsWith("TABLE"))
     {
         TableDefinitionParser.Parse(line, id);
         return;
     }
     else if (line.StartsWith("RULE"))
     {
         RuleDefinitionParser.Parse(line, id);
         return;
     }
     else if (line.StartsWith("DESTINATION"))
     {
         DestinationParser.Parse(line, id);
         return;
     }
     else
     {
         throw new ArgumentException("Invalid token at beginning of line: " + line);
     }
 }
        private void HeaderRowParserThrowsExceptionWhenLineIsNullEquivalent(string Line)
        {
            // Arrange
            var id = new ImportDefinition();

            // Act
            try
            {
                HeaderRowParser.Parse(Line, id);
                Assert.Fail("ArgumentNullException expected, not thrown.");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("Line", ex.ParamName);
            }
            catch (Exception ex)
            {
                Assert.Fail("ArgumentNullException expected, " +
                            ex.GetType().Name +
                            " thrown instead.");
            }
        }
        public void HeaderRowParserThrowsExceptionWhenLineHasTooManyTokens()
        {
            // Arrange
            var id = new ImportDefinition();
            var s  = "HEADERROW Has too many tokens";

            // Act
            try
            {
                HeaderRowParser.Parse(s, id);
                Assert.Fail("ArgumentException expected, not thrown.");
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("Header Row definition has too many tokens.",
                                ex.Message);
            }
            catch (Exception ex)
            {
                Assert.Fail("ArgumentException expected, " +
                            ex.GetType().Name +
                            " thrown instead.");
            }
        }
        public void HeaderRowParserThrowsExceptionWhenLineisNotHeaderRowDeclaration()
        {
            // Arrange
            var id = new ImportDefinition();
            var s  = "NOTAHEADERROW";

            // Act
            try
            {
                HeaderRowParser.Parse(s, id);
                Assert.Fail("ArgumentException expected, not thrown.");
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("Passed in string is not a HEADERROW declaration.",
                                ex.Message);
            }
            catch (Exception ex)
            {
                Assert.Fail("ArgumentException expected, " +
                            ex.GetType().Name +
                            " thrown instead.");
            }
        }