-
-
Save explorer14/2f0d56812f79c20f74cbdaa7b17b3ef7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public async Task ShouldPublishNotificationForSuccessfulRegistration() | |
{ | |
var customerRepositoryStub = CreateEmptyRepository(); | |
// Notice, I don't really care about the values in the request | |
// because I am testing the collaboration with the event bus | |
var testCustomerRegistrationRequest = CreateTestRequest(); | |
var eventBusMock = new Mock<IEventBus>(); | |
eventBusMock | |
.Setup(x=>x.Publish(It.IsAny<NewCustomerRegistered>())) | |
.ReturnsAsync(Task.CompletedTask) | |
.Verifiable(); | |
// Create the system under test with a stub and a mock | |
var useCase = new CustomerRegistrationUseCase( | |
customerRepositoryStub, | |
eventBusMock.Object); | |
await useCase.RegisterCustomer(testCustomerRegistrationRequest); | |
eventBusMock.Verify(x=>x.Publish(It.IsAny<NewCustomerRegistered>()), Times.Once); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment