Last active
August 25, 2019 12:37
-
-
Save explorer14/f7842eb74d51f01022c9b141709c13ed 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
public class GivenThereArePurchaseOrdersForTheProduct | |
{ | |
[Fact] | |
public async Task ShouldCreateValidSuggestion() | |
{ | |
var productId = {use a dummy id}; | |
// set up the stub to already have a purchase order stored | |
var poStore = new PurchaseOrderStoreStub() | |
.WithPurchaseOrder(...); | |
var productStore = new ProductStoreStub(); | |
var suggestionStore = new SuggestionStoreStub(); | |
// initialise the System Under Test passing in all the stubbed dependencies | |
var handler = new ProductInformationHandler( | |
new ReviewUseCase( | |
suggestionStore, | |
productStore, | |
poStore), | |
poStore, | |
productStore | |
); | |
// invoke the handle method (It doesn't matter if its invoked | |
// via an event arriving in a queue or by a test suite like this one) | |
// create a test event with canned values | |
await handler.Handle( | |
CreateTestEvent(...)); | |
// Time to assert on the output of handling the test event. | |
var savedProduct = await productStore.GetByProductId(productId); | |
var suggestionForProduct = await suggestionStore.GetFor(productId); | |
// Assert that incoming product was saved successfully | |
savedProduct.Should().NotBeNull(); | |
// Assert that as a result of an appropriate event, the suggestion was also created | |
// and stored in the "database" | |
suggestionForProduct.Should().NotBeNull(); | |
// various other assertions on suggestion attributes. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment