Beispiel #1
0
        public void ReadDataFromCsvFile_OverridesProvidedFields_CSVFieldOverridesProvided()
        {
            var               mockLogger       = new Mock <ILogger>();
            string            testFile         = "../../../Utilities/validdata.csv";
            CSVFieldOverrides withoutOverrides = new CSVFieldOverrides();

            Dictionary <string, string> fields = new Dictionary <string, string>();

            fields.Add("FIRST_NAME", "FIRST_NAME");
            fields.Add("LAST_NAME", "LAST_NAME");
            fields.Add("EMAIL", "EMAIL");
            fields.Add("SUPERVISOR", "SUPERVISOR");
            fields.Add("EMPLOYEE_ID", "EMPLOYEE_ID");
            fields.Add("LOCATION_TITLE", "LOCATION_TITLE");
            fields.Add("LOCATION_ABR", "LOCATION_ABR");
            fields.Add("GROUP_TITLE", "GROUP_TITLE");
            fields.Add("GROUP_ABR", "GROUP_ABR");
            CSVFieldOverrides withOverrides = new CSVFieldOverrides();

            withOverrides.Fields = fields;

            EverfiCSVReader reader = new EverfiCSVReader(mockLogger.Object, withOverrides);
            var             usersFromCSVWithOverride = reader.ReadDataFromCsvFile(testFile).ToList();

            foreach (var field in fields)
            {
                foreach (var user in usersFromCSVWithOverride)
                {
                    Assert.Matches(field.Value, user.GetType().GetProperty(field.Key).GetValue(user).ToString());
                }
            }
        }
Beispiel #2
0
        public void ReadDataFromCsvFile_FileDoesNotExist_ThrowsFileNotFound()
        {
            var             mockLogger = new Mock <ILogger>();
            string          testFile   = "../../../Utilities/doesnotexist.csv";
            EverfiCSVReader reader     = new EverfiCSVReader(mockLogger.Object);

            Assert.Throws <FileNotFoundException>(() => reader.ReadDataFromCsvFile(testFile));
        }
Beispiel #3
0
        public void ReadDataFromCsvFile_InvalidDataFromCSV_ReturnsEmptyList()
        {
            var             mockLogger = new Mock <ILogger>();
            string          testFile   = "../../../Utilities/invaliddata.csv";
            EverfiCSVReader reader     = new EverfiCSVReader(mockLogger.Object);

            var usersFromCSV = reader.ReadDataFromCsvFile(testFile);

            Assert.Empty(usersFromCSV);
        }
Beispiel #4
0
        public void ReadDataFromCsvFile_ValidCSVFile_ReturnsListOfEverfiUser()
        {
            var             mockLogger = new Mock <ILogger>();
            string          testFile   = "../../../Utilities/validdata.csv";
            EverfiCSVReader reader     = new EverfiCSVReader(mockLogger.Object);

            var usersFromCSV = reader.ReadDataFromCsvFile(testFile).ToList();

            Assert.NotEmpty(usersFromCSV);
        }
        private IEnumerable <EverfiUser> GetEverfiUsersFromCSV()
        {
            EverfiCSVReader csvReader = new EverfiCSVReader(logger, fieldOverrides);

            return(csvReader.ReadDataFromCsvFile(csvFile.FullName));
        }