UnitTestingAndBenchmarkingExample
A practice repo pairing xUnit tests with BenchmarkDotNet benchmarks โ because "it works" and "it works fast enough" are answered with different tools.
What it demonstrates
A small InventoryService has two versions of the same method: AddStock_Old, which just appends a stock entry, and AddStock, which adds a duplicate-product check first. Unit tests cover both for correctness, and a BenchmarkDotNet benchmark (with [MemoryDiagnoser]) measures what that extra check actually costs in time and allocations โ turning "this is probably fine" into a number.
Why it exists
Built as a learning/practice project, not for a specific work problem โ a place to get comfortable pairing tests and benchmarks on the same piece of code, rather than treating them as separate concerns.
Technology
.NET, C#, xUnit, BenchmarkDotNet
View on GitHub โ