The Timesheet System is an ASP.NET MVC application designed for tracking work hours across projects. Developed with a Test-Driven Development (TDD) approach, this application ensures reliable functionality for entering, managing, and exporting timesheet data, with built-in validation and automated tests.
The application is organized into the following core directories:
- Controllers: Manages HTTP requests, directs data flow, and renders views.
- Models: Defines data structures, including the primary
TimesheetEntrymodel. - Views: Contains Razor views that define the user interface.
- Services: Implements core functionality such as data processing and business logic.
- Tests: Houses unit tests developed through TDD to ensure functionality across the application.
This project was developed using a Test-Driven Development (TDD) approach. Below is an outline of the primary features and their development process:
-
Model Definition
- Created the
TimesheetEntrymodel with key properties:UserName,Date,ProjectName,Description, andHoursWorked. - Wrote unit tests to verify that each property is correctly defined and accessible.
- Created the
-
In-Memory Database (TimesheetService)
- Implemented
TimesheetServiceto simulate data storage in an in-memory database. - Created tests to validate all CRUD operations and to ensure accurate total hours calculation.
- Implemented
-
Timesheet Entry Form and Listing
- Developed the timesheet entry form and listing view to allow users to add and view timesheet entries.
- Added controller tests to confirm functionality for adding and retrieving entries.
-
Form Validation
- Implemented validation to restrict
HoursWorkedto a maximum of 24 hours and ensureDescriptionis not empty. - Created validation tests to ensure inputs meet these criteria.
- Implemented validation to restrict
- Enhanced hour calculation logic to aggregate total hours per user and day.
- Added tests to confirm accurate calculations, even with multiple entries on the same date.
-
CSV Export Logic
- Developed logic to export timesheet data to a CSV format, ensuring data integrity and accurate aggregation of total hours.
- Created tests to validate CSV file structure, headers, and aggregation.
-
Export View
- Added an "Export to CSV" button in the listing view to enable users to download timesheet data.
-
TimesheetService Tests
- Verified comprehensive test coverage for all CRUD and calculation operations.
- Added edge case tests to cover scenarios like single vs. multiple entries and various user/date combinations.
-
CSV Export Tests
- Verified that the CSV export tests cover structure, headers, and aggregation accuracy.
Each feature was implemented using TDD as follows:
-
Write Tests First
Tests were written first to define expected functionality, setting clear requirements before coding. -
Code Implementation
Code was then written to pass the tests, ensuring functionality adhered to test specifications. -
Refinement and Optimization
Once tests were passing, the code was refined and optimized while maintaining functionality.
-
Code Documentation
- Inline comments were added throughout the codebase to explain key functionalities and design choices.
-
Manual Testing
- In addition to automated tests, manual testing was conducted to confirm UI elements and CSV export accuracy.