Example #1
0
        /// <summary>
        /// Entry point method
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public async Task <bool> Run(string[] args)
        {
            try
            {
                //Checking for command validation
                var validationCheck = CommandValidator.IsCommandValid(args);
                if (validationCheck)
                {
                    //Site type checks
                    if (args[1] == Constant.Capterra)
                    {
                        await _productService.AddCapterraProductsAsync(FilePathResolver.ResolveFilePath(args));
                    }

                    if (args[1] == Constant.Softwareadvice)
                    {
                        await _productService.AddSoftwareAdviceProductsAsync(FilePathResolver.ResolveFilePath(args));
                    }
                }

                return(true);
            }
            catch (Exception)
            {
                Console.WriteLine("Invalid Operation, please try again with valid commands");
                return(false);
            }
        }
        public void FilePathResolverReturnsFilePathWithFileName()
        {
            const string fileName = "Test_File.csv";

            string filePath = FilePathResolver.ResolveFilePath(fileName);

            Assert.IsTrue(filePath.EndsWith(fileName));
        }
        public void FilePathResolverReturnsFilePath()
        {
            const string fileName = "Test_File.csv";

            string filePath = FilePathResolver.ResolveFilePath(fileName);

            Assert.IsFalse(string.IsNullOrEmpty(filePath));
        }
        public void FilePathResolverReturnsExpectedFilePath()
        {
            const string fileName = "Test_File.csv";
            string       expected = AppDomain.CurrentDomain.BaseDirectory + fileName;

            string filePath = FilePathResolver.ResolveFilePath(fileName);

            Assert.AreEqual(expected, filePath);
        }