Skip to content

Fix AddNewOrder test validation and integration event discovery#1001

Open
onurnafiguzel wants to merge 1 commit into
dotnet:mainfrom
onurnafiguzel:fix/ordering-functionaltests-addneworder-943
Open

Fix AddNewOrder test validation and integration event discovery#1001
onurnafiguzel wants to merge 1 commit into
dotnet:mainfrom
onurnafiguzel:fix/ordering-functionaltests-addneworder-943

Conversation

@onurnafiguzel

Copy link
Copy Markdown

Fixes #943

Problem

The AddNewOrder functional test in Ordering.FunctionalTests passed even though the
order was never actually created. Issue #943 identified three underlying problems:

  1. Validation failures were masked. CreateOrderAsync always returned 200 OK, even
    when the command failed, so an invalid request looked successful.
  2. DateTime.Kind mismatch. The test built the card expiration date with
    Convert.ToDateTime(...), producing Kind.Local, which Npgsql rejects for
    timestamp with time zone columns.
  3. Integration event types could not be resolved under tests.
    IntegrationEventLogService loaded event types from Assembly.GetEntryAssembly().
    In functional tests the entry assembly is the test host, which does not contain the
    derived IntegrationEvent types, so publishing an order's integration event threw and
    returned 500.

Changes

  • OrdersApi.CreateOrderAsync: now returns BadRequest when the command fails,
    consistent with the Cancel/Ship endpoints, instead of always returning Ok.
  • IntegrationEventLogService: the assembly to scan for event types is now injected
    via the constructor instead of relying on the entry assembly.
  • Ordering.API / Catalog.API DI registration: each API now passes its own
    assembly (typeof(Extensions).Assembly) when registering the log service.
  • OrderingApiTests:
    • Renamed the existing invalid-data test to AddNewOrderWithInvalidDataFails
      (asserts BadRequest).
    • Added a new AddNewOrder test using valid data (future UTC expiration date, complete
      address, valid security number) that asserts OK.

Testing

  • Ordering.FunctionalTests: 12/12 passing
  • Ordering.UnitTests: 41/41 passing

@onurnafiguzel

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

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.

AddNewOrder in Ordering.FunctionalTests is not properly tested

1 participant