예제 #1
0
        public void NullDataTableReaderTest()
        {
            string            _filePath = @"E:\Learning\Visual Studio 2015 Projects\FileViewer\FileViewer\App_Data\WithHeaderData.csv";
            CsvDataRepository _csvRepo  = new CsvDataRepository(_filePath, new CsvStreamReader(), null);

            Assert.IsNotNull(_csvRepo.Get());
        }
예제 #2
0
        public void NullFilePathTest()
        {
            string            _filePath = null;
            CsvDataRepository _csvRepo  = new CsvDataRepository(_filePath, new CsvStreamReader(), new DataTableConverter());

            Assert.IsNotNull(_csvRepo.Get());
        }
        public static void ClassInitialize(TestContext context)
        {
            var dataDirectory = ConfigurationManager.AppSettings["TestDataDirectory"];
            var c45Source = File.ReadAllText(Path.Combine(dataDirectory, "C4.5.txt"));
            var forexTreePath = Path.Combine(ConfigurationManager.AppSettings["TestDataDirectory"], "ForexTree.data");
            _repository = new CsvDataRepository<ForexTreeData>();
            _repository.LoadData(forexTreePath);
            _repository.NormalizeData(0);

            _tree = new DecisionTree<ForexTreeData>(
                        new DecisionTreeReader(),
                        new RuleBuilder(),
                        new Classifier<ForexTreeData>()
                    );

            _tree.SaveDecisionTree(c45Source);
        }
예제 #4
0
        public static void ClassInitialize(TestContext context)
        {
            var dataDirectory = ConfigurationManager.AppSettings["TestDataDirectory"];
            var c45Source     = File.ReadAllText(Path.Combine(dataDirectory, "C4.5.txt"));
            var forexTreePath = Path.Combine(ConfigurationManager.AppSettings["TestDataDirectory"], "ForexTree.data");

            _repository = new CsvDataRepository <ForexTreeData>();
            _repository.LoadData(forexTreePath);
            _repository.NormalizeData(0);

            _tree = new DecisionTree <ForexTreeData>(
                new DecisionTreeReader(),
                new RuleBuilder(),
                new Classifier <ForexTreeData>()
                );

            _tree.SaveDecisionTree(c45Source);
        }
        public void WhenILoadStudentTestData()
        {
            var studentInfo = new CsvDataRepository().GetStudentInfo();

            _scenarioContext.Add(StudentInfoData, studentInfo);
        }
예제 #6
0
 public void TestInitialize()
 {
     _dataRepository = new CsvDataRepository <YahooRecord>();
     _dataFilePath   = ConfigurationManager.AppSettings["TestDataDirectory"] + "\\TestData.csv";
 }
예제 #7
0
        public ActionResult Index(HttpPostedFileBase uploadedFile)
        {
            DataTable csvTable = new DataTable();

            if (uploadedFile != null && uploadedFile.ContentLength > 0)
            {
                var upldFileName = Path.GetFileName(uploadedFile.FileName);
                var upldFilePath = Path.Combine(Server.MapPath("~/App_Data/"), upldFileName);
                uploadedFile.SaveAs(upldFilePath);

                /*-- 1st Pass --*/
                #region Achieved basic functinality, In order to make code maintainable , refactored it using Interface drive development
                //string csvText;
                //using (StreamReader strmReader = new StreamReader(upldFilePath))
                //{
                //    while (!strmReader.EndOfStream)
                //    {
                //        csvText = strmReader.ReadToEnd().ToString();
                //        string[] readRows = csvText.Split('\n');


                //        for (int i = 0; i < readRows.Count() - 1; i++)
                //        {
                //            string[] rowValues = readRows[i].Split(','); //split each row with comma to get individual values
                //            {
                //                if (i == 0)
                //                {
                //                    for (int j = 0; j < rowValues.Count(); j++)  //add headers
                //                    {
                //                        csvTable.Columns.Add(rowValues[j]);
                //                    }
                //                }
                //                else
                //                {
                //                    DataRow dr = csvTable.NewRow(); //adding rows here
                //                    for (int k = 0; k < rowValues.Count(); k++)
                //                    {
                //                        dr[k] = rowValues[k].ToString();
                //                    }
                //                    csvTable.Rows.Add(dr);
                //                }
                //            }
                //        }

                //    }
                //}
                #endregion
                /*---------------------------------------------------------------------------------------------------------------*/

                /*-- 2nd Pass, by refactoring code --*/

                //1st Approach to read file using Stream Reader
                IDataRepository csvDataRepo = new CsvDataRepository(upldFilePath, new CsvStreamReader(), new DataTableConverter());

                //2nd Approach  to read file -- For now it has been commmented
                //IDataRepository csvDataRepo = new CsvDataRepository(upldFilePath, new FileReader(new ConsoleWriter()), new DataTableConverter());

                /*---------------------------------------------------------------------------------------------------------------------------------*/
                csvTable = csvDataRepo.Get();
            }
            return(View(csvTable));
        }
 public void TestInitialize()
 {
     _dataRepository = new CsvDataRepository<YahooRecord>();
     _dataFilePath = ConfigurationManager.AppSettings["TestDataDirectory"] + "\\TestData.csv";
 }