public void ParseReturnsCSVFileType()
        {
            // Arrange
            var line = "FILETYPE CSV";
            var id   = new ImportDefinition();

            // Act
            FileTypeParser.Parse(line, id);

            // Assert
            Assert.AreEqual(Enums.FileTypes.CSV, id.FileType);
        }
 public void ParseThrowsExceptionWhenImportDefinitionIsNull()
 {
     // Act
     try
     {
         FileTypeParser.Parse("FILETYPE EXCEL", 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.");
     }
 }
Exemplo 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 ParseThrowsExceptionWhenLineIsNullEquivalent(string Line)
        {
            // Arrange
            var id = new ImportDefinition();

            try
            {
                FileTypeParser.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 ParseThrowsExceptionWhenFILETYPEDeclarationIsNotComplete()
        {
            // Arrange
            var id   = new ImportDefinition();
            var line = "FILETYPE";

            try
            {
                FileTypeParser.Parse(line, id);
                Assert.Fail("ArgumentException expected, not thrown.");
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("FILETYPE row does not specify a file type value.",
                                ex.Message);
            }
            catch (Exception ex)
            {
                Assert.Fail("ArgumentException expected, " +
                            ex.GetType().Name + " thrown instead.");
            }
        }
        public void ParseThrowsExceptionWhenLineDoesNotStartWithFILETYPE()
        {
            // Arrange
            var id   = new ImportDefinition();
            var line = "NOT FILETYPE";

            try
            {
                FileTypeParser.Parse(line, id);
                Assert.Fail("ArgumentException expected, not thrown.");
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("Line is not a FILETYPE declaration.",
                                ex.Message);
            }
            catch (Exception ex)
            {
                Assert.Fail("ArgumentException expected, " +
                            ex.GetType().Name + " thrown instead.");
            }
        }
        public void ParseThrowsExceptionWhenFileTypeIsInvalidValue()
        {
            // Arrange
            var id   = new ImportDefinition();
            var line = "FILETYPE INVALIDVALUE";

            try
            {
                FileTypeParser.Parse(line, id);
                Assert.Fail("ArgumentException expected, not thrown.");
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("FILETYPE declaration value of INVALIDVALUE is not a valid file type.",
                                ex.Message);
            }
            catch (Exception ex)
            {
                Assert.Fail("ArgumentException expected, " +
                            ex.GetType().Name + " thrown instead.");
            }
        }