Skip to content

daiman411/AutoCheckoutPosSystem

Repository files navigation

AutoCheckoutPosSystem

An automatic checkout POS (Point of Sale) system with comprehensive unit testing.

Overview

This project demonstrates a modular, well-tested checkout system designed for demo purposes. It includes core functionalities like product management, shopping cart operations, payment processing, and receipt generation.

Project Structure

AutoCheckoutPosSystem/
├── src/
│   └── AutoCheckoutPosSystem/
│       ├── Models/
│       │   ├── Product.cs          # Product entity
│       │   └── CartItem.cs         # Shopping cart item
│       └── Services/
│           ├── ShoppingCart.cs     # Cart management
│           ├── PaymentProcessor.cs # Payment processing
│           └── ReceiptGenerator.cs # Receipt generation
├── tests/
│   └── AutoCheckoutPosSystem.Tests/
│       ├── Models/                 # Model unit tests
│       └── Services/               # Service unit tests
└── AutoCheckoutPosSystem.sln       # Solution file

Features

  • Product Management: Create and manage products with validation
  • Shopping Cart: Add, remove, and update items with quantity management
  • Payment Processing: Support for multiple payment methods (Cash, Credit Card, Debit Card, Mobile Payment)
  • Receipt Generation: Generate formatted receipts with tax calculation
  • Comprehensive Testing: 68 unit tests with 99.4% code coverage

Getting Started

Prerequisites

  • .NET 10.0 SDK or later

Building the Project

dotnet build

Running the Demo Application

To see the system in action:

dotnet run --project src/AutoCheckoutPosSystem/AutoCheckoutPosSystem.csproj

This will demonstrate:

  • Creating products
  • Adding items to a shopping cart
  • Processing a payment
  • Generating a formatted receipt

Running Tests

Run all tests:

dotnet test

Run tests with detailed output:

dotnet test --logger "console;verbosity=detailed"

Run tests with code coverage:

dotnet test --collect:"XPlat Code Coverage"

The coverage report will be generated in tests/AutoCheckoutPosSystem.Tests/TestResults/ directory.

Testing

Test Structure

The test project (AutoCheckoutPosSystem.Tests) uses xUnit as the testing framework and includes:

  • Model Tests: Validation of Product and CartItem entities
  • Service Tests: Testing of ShoppingCart, PaymentProcessor, and ReceiptGenerator services

Test Coverage

Current test coverage: 99.4% (170/171 lines covered)

The test suite includes:

  • 68 total test cases
  • Unit tests for all core functionalities
  • Edge case and failure scenario testing
  • Parameter validation tests using xUnit Theory and InlineData

Running Specific Tests

Run tests for a specific namespace:

dotnet test --filter "FullyQualifiedName~AutoCheckoutPosSystem.Tests.Models"
dotnet test --filter "FullyQualifiedName~AutoCheckoutPosSystem.Tests.Services"

Run a specific test:

dotnet test --filter "FullyQualifiedName~ProductTests.Constructor_WithValidParameters_CreatesProduct"

Code Coverage Tools

This project uses:

  • Coverlet: For code coverage collection
  • Cobertura: Coverage report format

To view coverage results in detail, you can use tools like:

  • ReportGenerator
  • Visual Studio Code with Coverage Gutters extension
  • IDEs like Visual Studio or Rider with built-in coverage viewers

Development

Adding New Tests

  1. Create a new test class in the appropriate directory under tests/AutoCheckoutPosSystem.Tests/
  2. Follow the naming convention: {ClassName}Tests.cs
  3. Use xUnit attributes: [Fact] for single tests, [Theory] with [InlineData] for parameterized tests
  4. Follow the Arrange-Act-Assert pattern

Example:

[Fact]
public void MethodName_Scenario_ExpectedBehavior()
{
    // Arrange
    var sut = new ClassUnderTest();
    
    // Act
    var result = sut.Method();
    
    // Assert
    Assert.Equal(expectedValue, result);
}

License

This is a demo project for educational purposes.

About

automatic checkout pos system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published