Skip to content

Conversation

scleaver
Copy link
Contributor

This pull request introduces unit tests for the EntityBase, DomainEventBase, ValueObject, and MediatRDomainEventDispatcher classes in the SharedKernel project. The tests were written using xUnit, FluentAssertions, and Moq to ensure the correct behavior of these classes.

Here's a brief overview of the tests added:

  1. EntityBaseTests: These tests ensure that domain events are correctly added.
  2. DomainEventBaseTests: This test ensures that the DateOccurred property is set to the current date and time when a new domain event is created.
  3. ValueObjectTests: These tests ensure that two value objects with the same values are considered equal and have the same hash code. They also test the behavior when comparing value objects with different values.
  4. MediatRDomainEventDispatcherTests: This test ensures that the Publish method is called for each domain event in an entity and that the ClearDomainEvents method is called on the entity after the events have been dispatched.

These tests increase the test coverage of the project and provide a safety net for future changes. They also serve as examples for how to write tests for these types of classes in a domain-driven design (DDD) application.

@scleaver
Copy link
Contributor Author

@ardalis - please let me know if you would like changes for these tests and I will update. Also the MediatRDomainEventDispatcherTests is not passing and I feel that it should be (unless I have made a mistake). Could you verify.

@ardalis ardalis self-requested a review July 31, 2023 13:07
@ardalis ardalis merged commit b5bb826 into ardalis:main Jul 31, 2023
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.

2 participants