Skip to content

Using Visual Studio and C#, create a console-based app that will create a dictionary object that returns in the console the counts of employees in each department

Notifications You must be signed in to change notification settings

wonhee3472/Console_App_CSV_Parser

Repository files navigation

Console_App_CSV_Parser

Using Visual Studio and C#, create a console-based app that will create a dictionary object that returns in the console the counts of employees in each department

  1. Copied and pasted the given CSV file to the project folder and changed the Copy to Output Directory property to Copy always:

image

  1. Created a class Employee.cs to read the CSV file (15 fields/columns to read) and inserted CsvColumn attributes since the first line in the CSV file are the field/column names:

image

  1. Defined a method called ReadCsvFile() in Program.cs:

image

  1. Calling ReadCsvFile() inside the Main method and Console.ReadKey() to see the output on the console:

image

  1. Output on the console:

image

Include any thoughts and or examples on how you might test this

  • To see if the counts of employees get incremented correctly, I tried setting the breakpoint at the line 52:

image

  • If I run the app with the breakpoint at the line 52, the code should've completed its iteration over the first employee object which is this employee:

image

  • And if I actually run the app, we can find that that's the case and the engineering department has the count of 1:

image

  • Now, I'd like to see if the count of engineering department gets incremented once it encounters the next employee whose department is also engineering. The next engineering employee in line is Harper Dominguez.

image

  • And if I keep running the app, I can see that the department of engineering has the count of 2 at the employee Harper Dominguez:

image

Additional thoughts

Not sure how to do unit test yet, but I thought it'd be good to do something like the followings:

  • Divide the employee.csv file into several sample csv files;
  • Add test data into each of them;
  • Verify if the app still outputs the expected values

About

Using Visual Studio and C#, create a console-based app that will create a dictionary object that returns in the console the counts of employees in each department

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages