CanDriveClass Project
Overview This repository contains the CanDriveClass solution, developed as part of the CSD268 QA Methodologies final project. The project demonstrates object-oriented programming principles in C#, encapsulation through controlled property access, and rigorous quality assurance practices using Xunit for automated testing. The central component is the DriverChecker class, which models the logic for determining whether a person of a given age is legally eligible to drive. The accompanying test suite validates the class against boundary conditions, invalid inputs, and expected outcomes.
Features
- Encapsulated Class Design
- Private field age with controlled access via the Age property.
- Factory method Create(int age) for safe instantiation.
- Validation ensuring age values fall within the range of 1–100.
- CanDrive() method enforcing the minimum driving age of 16.
- Comprehensive Unit Testing
- Implemented with Xunit.
- Tests cover:
- Boundary conditions (negative values, extreme integers).
- Valid driving ages (13–18).
- Exception handling for invalid inputs.
- Ensures correctness, reliability, and adherence to QA methodologies.
Project Structure CanDriveProject/ └── CanDriveClass/ └── DriverChecker.cs # Main class implementation CandriveTest/ └── UnitTest1.cs # Xunit test cases
Getting Started Prerequisites
- .NET 8.0 SDK or later
- Xunit test framework (included via NuGet)
Installation Clone the repository: git clone https://github.com/your-username/CanDriveClass.git cd CanDriveClass
Build dotnet build
Run Tests dotnet test
Usage Example using CanDriveClass; var driver = DriverChecker.Create(18);
if (driver.CanDrive()) { Console.WriteLine("You are old enough to drive."); } else { Console.WriteLine("You cannot drive yet."); }
Sample Test [Fact] public void CanDriveTest7() { var driver = new DriverChecker { Age = 16 }; bool canDrive = driver.CanDrive(); Assert.True(canDrive); }
Learning Outcomes This project demonstrates:
- Application of object-oriented design principles (encapsulation, constructors, factory methods).
- Defensive programming with validation and exception handling.
- Development of unit tests using Xunit.
- Structuring a C# solution with dependencies and references.
- Practical application of QA methodologies to ensure software reliability.
License This project was developed for educational purposes as part of the CSD268 QA Methodologies course. It may be freely used, forked, or extended for learning and experimentation.