public void ExcelLoad_LoadRecordsFromSpreadsheet_AllCellsCorrect()
        {
            //arrange
            var loadExcel = new ExcelLoad();
            //act
            var result = loadExcel.LoadExcelFile(correctFilePath);

            // Assert
            Assert.Equal(10, result.Count());
        }
        public void ExcelLoad()
        {
            //arrange
            var loadExcel = new ExcelLoad();
            //act
            var result    = loadExcel.LoadExcelFile(correctFilePath);
            var foundName = result.Where(w => w.FirstName == testName).FirstOrDefault();

            // Assert
            Assert.Equal(testName, foundName.FirstName);
        }
        public void ReadExcelFile()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                InitialDirectory = @"C:\Users\CzarnyPotwor\Desktop",
                Filter           = "Excel files (*.xlsx)|*.xlsx",
                FilterIndex      = 0,
                RestoreDirectory = true
            };

            if (openFileDialog.ShowDialog() == true)
            {
                SelectedFileNamePath = openFileDialog.FileName;
                var fromExcelList = excelLoad.LoadExcelFile(SelectedFileNamePath).ToList();
                foreach (var person in fromExcelList)
                {
                    PersonList.Add(person);
                }
            }
        }
Esempio n. 4
0
        public void ReadExcelFile()
        {
            //use var if we clearly know what variable type we create - MD
            var openFileDialog = new OpenFileDialog
            {
                InitialDirectory = ConfigurationManager.AppSettings["InitialDirectory"],
                Filter           = ConfigurationManager.AppSettings["Filter"],
                FilterIndex      = int.Parse(ConfigurationManager.AppSettings["FilterIndex"]),
                RestoreDirectory = bool.Parse(ConfigurationManager.AppSettings["RestoreDirectory"])
            };

            if (openFileDialog.ShowDialog() == true)
            {
                SelectedFileNamePath = openFileDialog.FileName;
                var fromExcelList = excelLoad.LoadExcelFile(SelectedFileNamePath).ToList();

                foreach (var person in fromExcelList)
                {
                    PersonList.Add(person);
                }
            }
        }