Skip to content

tomajexpress/CommandProcessor

Repository files navigation

Command Processor

.NET [Architecture] License

📖 Overview

A robust, enterprise-grade C# console application demonstrating the Command Design Pattern and Dependency Injection with a "Fortress" architecture. This project allows users to perform arithmetic operations with full Undo capabilities.

🏗️ Architecture: The "Fortress" Model

This solution is divided into two distinct layers to ensure strict Separation of Concerns and Data Integrity:

  • CommandProcessor.Core (Class Library): The "Fortress." All business logic, the Calculator state, and specific ICommand implementations are marked as internal. They are inaccessible to the UI, preventing external tampering.

  • CommandProcessor.Console (Console App): The UI layer. It interacts only with the ICommandManager interface and is responsible for user input and output.

  • CommandProcessor.Tests (xUnit): A comprehensive suite of unit tests to verify the Undo stack and DI container registration.

🛠️ Design Patterns Used

  • Command Pattern: Encapsulates requests as objects.

  • Service Locator (via IoC): Used within the Manager to resolve commands.

  • Facade: The CommandManager acts as the single point of entry for the Core library.

✨ Key Features

  • Undo Support: Every command is reversible. The system uses a LIFO (Last-In-First-Out) stack to track operations.

  • Modern DI (.NET 10): Leverages Keyed Services to resolve commands dynamically at runtime based on user input.

  • Type Safety: Uses Enums for command identification instead of error-prone magic strings.

  • Unit Tested: Isolated testing of the Command Manager.

Supported Commands

Command Description
increment Adds 1 to the current value.
decrement Subtracts 1 from the current value.
double Multiplies the current value by 2.
randadd Adds a random number (1-100) to the value.
undo Reverts the last operation.
exit Terminates the application.

🚀 Getting Started

Prerequisites

✅ .NET 9.0 SDK (or later)

✅ Visual Studio 2022 / VS Code

🧪 Testing

The solution includes xUnit tests that verify the internal logic of the core library.

🤝 Contributing

Contributions are welcome! Please ensure that any PR maintains the "Green" status of the Tests.

✍️ Author

Aman Toumaj Senior Software Developer & Architecture Enthusiast

Medium

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages