Add unit tests for DisposableEvent (void and generic types)#27
Conversation
Co-authored-by: Hissal <89788928+Hissal@users.noreply.github.com>
Co-authored-by: Hissal <89788928+Hissal@users.noreply.github.com>
Co-authored-by: Hissal <89788928+Hissal@users.noreply.github.com>
Hissal
left a comment
There was a problem hiding this comment.
Check the file for the generic typed DisposableEvent tests and mirror how those are substituted and checked.
Also add missing tests to the generic event that have been added to the void one such as the incremental handlercount tests.
Co-authored-by: Hissal <89788928+Hissal@users.noreply.github.com>
Updated VoidDisposableEventTest to mirror the generic DisposableEventTest pattern using |
The non-generic
DisposableEventclass lacked test coverage, and the genericDisposableEvent<T>class was missing some tests. Added comprehensive test suite covering all public APIs and edge cases for both types.Changes Made
VoidDisposableEventTest.cs - 12 tests for non-generic
DisposableEvent:IEventHandler<Void>[]handlers array with NSubstitute mocksDisposableEventTest.cs - Enhanced with 2 additional tests:
HandlerCount_IncrementsWithEachSubscription- validates handler count increases as subscriptions are addedHandlerCount_DecrementsWhenSubscriptionDisposed- validates handler count decreases as subscriptions are disposedTest Patterns
Both test files now follow consistent patterns:
sutnaming convention for the system under testMethodName_Scenario_ExpectedBehaviornaming conventionReceived()/DidNotReceive()verificationAssert.Allfor collection assertionsTesting
The changes ensure both the generic and non-generic DisposableEvent classes have comprehensive, consistent test coverage.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.