Skip to content

test: add Stock value object unit tests - #252

Open
varnika-dev wants to merge 2 commits into
mehdihadeli:mainfrom
varnika-dev:test/add-stock-value-object-unit-tests
Open

test: add Stock value object unit tests#252
varnika-dev wants to merge 2 commits into
mehdihadeli:mainfrom
varnika-dev:test/add-stock-value-object-unit-tests

Conversation

@varnika-dev

Copy link
Copy Markdown

What this PR adds

Added first unit tests for the Stock value object in the Catalogs service.

Tests Added (4 tests)

  1. Should_Create_Stock_When_All_Values_Are_Valid
    → Stock.Of(10, 5, 100) creates successfully with correct values

  2. Should_Throw_When_Available_Exceeds_MaxStockThreshold
    → Stock.Of(600, 5, 100) throws MaxStockThresholdReachedException

  3. Should_Throw_When_Available_Is_Zero
    → Stock.Of(0, 5, 100) throws zero stock not allowed

  4. Should_Throw_When_RestockThreshold_Is_Zero
    → Stock.Of(10, 0, 100) throws Zero restock threshold not allowed

Also Fixed

  • global.json SDK version updated from 9.0.303 to 9.0.115
    to match locally installed .NET SDK

Why Stock

Stock is the most complex value object in the domain
it owns 3 values and enforces a cross-field business rule
(Available cannot exceed MaxStockThreshold).
It is the highest value target for unit testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant