Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class GivenThereArePurchaseOrdersForTheProduct
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()
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(
// 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(
// 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
// Assert that as a result of an appropriate event, the suggestion was also created
// and stored in the "database"
// various other assertions on suggestion attributes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.