public void ShouldThrowFileNotFoundException(string userInput) { string outputFormat = "importing: Name: \"{0}\"; Categories: {1}; Twitter: {2}"; ProductImporter.ProductImporter productImporter = new ProductImporter.ProductImporter(outputFormat); var ex = Assert.Throws <FileNotFoundException>(() => productImporter.ImportProductDetails(userInput)); }
static void Main(string[] args) { try { SetUpConfig(); Console.WriteLine("Please enter path of file to import. Sytax: <import> <capterra/softwareadvice/..> <file full path>"); //input ex1: "import softwareadvice feed-products/softwareadvice.json"; //input ex2: "import capterra feed-products/capterra.yaml";// //string userInput = "import capterra feed-products/capterra.yaml"; string userInput = Console.ReadLine(); //string outputFormat = "importing: Name: \"{0}\"; Categories: {1}; Twitter: {2}"; ProductImporter productImporter = new ProductImporter(outputFormat); var feeds = productImporter.ImportProductDetails(userInput); foreach (var feed in feeds) { Console.WriteLine(feed);// or feeds could be written in a text file. } } catch (Exception ex) { Console.WriteLine($"Error Message: {ex.Message}"); } Console.WriteLine("Press key to exit!"); Console.ReadKey(); }
public void ShouldThrowException_ProviderNotSupported(string userInput) { string outputFormat = "importing: Name: \"{0}\"; Categories: {1}; Twitter: {2}"; ProductImporter.ProductImporter productImporter = new ProductImporter.ProductImporter(outputFormat); var ex = Assert.Throws <InvalidOperationException>(() => productImporter.ImportProductDetails(userInput)); Assert.Equal("Provider not supported!", ex.Message); }
public void ShouldThrowInvalidOpException(string userInput) { string outputFormat = "importing: Name: \"{0}\"; Categories: {1}; Twitter: {2}"; ProductImporter.ProductImporter productImporter = new ProductImporter.ProductImporter(outputFormat); var ex = Assert.Throws <InvalidOperationException>(() => productImporter.ImportProductDetails(userInput)); Assert.Equal("Invalid input! Valid Syntax: <import> <capterra/softwareadvice/..> <file full path>", ex.Message); }
public void ShouldImportProductDetails(string userInput) { string outputFormat = "importing: Name: \"{0}\"; Categories: {1}; Twitter: {2}"; ProductImporter.ProductImporter productImporter = new ProductImporter.ProductImporter(outputFormat); var feeds = productImporter.ImportProductDetails(userInput); int resultLen = feeds != null ? feeds.Count : 0; Assert.NotNull(feeds); Assert.True(resultLen > 0); }