Exemple #1
0
        public void ParseTableNameAddsTableNameToImportDefinition()
        {
            // Arrange
            var id = new ImportDefinition();
            var s  = "TABLENAME customTableName";

            // Act
            TableDefinitionParser.Parse(s, id);

            // Assert
            Assert.AreEqual("customTableName", id.TableName);
        }
Exemple #2
0
 public void ParsetableNameThrowsExceptionWhenImportDefinitionIsNull()
 {
     try
     {
         TableDefinitionParser.Parse("A line", 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.");
     }
 }
Exemple #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);
     }
 }
Exemple #4
0
        private void ParseTableNameThrowsExceptionWhenLineIsNullEquivalent(string line)
        {
            // Arrange
            var id = new ImportDefinition();

            try
            {
                TableDefinitionParser.Parse(line, id);
                Assert.Fail("ArgumentNullException expected, not thrown.");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("Line", ex.ParamName);
            }
            catch (Exception ex)
            {
                Assert.Fail("Expected ArgumentNullException, " +
                            ex.GetType().Name +
                            " thrown instead.");
            }
        }
Exemple #5
0
        public void ParseTableNameThrowsExceptionWhenLineIsNotTableNameDeclaration()
        {
            // Arrange
            var id = new ImportDefinition();
            var s  = "NOTATABLE";

            // Act
            try
            {
                TableDefinitionParser.Parse(s, id);
                Assert.Fail("ArgumentException expected, not thrown.");
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("Line is not a TABLENAME declaration.", ex.Message);
            }
            catch (Exception ex)
            {
                Assert.Fail("ArgumentException expected, " +
                            ex.GetType().ToString() +
                            " thrown instead.");
            }
        }
Exemple #6
0
        public void ParseTableNameThrowsExceptionWhenTooManyTokens()
        {
            // Arrange
            var id = new ImportDefinition();
            var s  = "TABLENAME too many tokens";

            // Act
            try
            {
                TableDefinitionParser.Parse(s, id);
                Assert.Fail("ArgumentException expected, not thrown.");
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("TABLE definition has too many tokens: " + s,
                                ex.Message);
            }
            catch (Exception ex)
            {
                Assert.Fail("ArgumentException expected, " +
                            ex.GetType().ToString() +
                            " thrown instead.");
            }
        }