public async void ShouldUpdateRecipeCorrectly() { // "051F13A0-4796-4B1C-9797-EC99F08CF25E" - sample recipe id to update var command = new UpdateRecipe { EntityId = new Guid("051F13A0-4796-4B1C-9797-EC99F08CF25E"), Name = "sample-name", Description = "sample-description", PictureUrl = "https://example.com/sample-picture.png", Calories = 1234, MealTypes = new[] { MealType.Snack }, Steps = new[] { "1. Sample first step.", "2. Sample second step." }, Ingredients = new[] { "Sample first ingredient", "Sample second ingredient" } }; var eventStore = new Mock <IEventStore <Recipe> >(); var handler = new UpdateRecipeHandler(eventStore.Object, MockBuilder.BuildFakeRecipeEventsMapper(), MockBuilder.BuildFakeCurrentUserService(), MockBuilder.BuildFakeDateTimeService()); await handler.Handle(command, CancellationToken.None); var expected = new RecipeUpdated { EntityId = new Guid("051F13A0-4796-4B1C-9797-EC99F08CF25E"), Published = new DateTime(2010, 1, 1), Version = 0, AuthorId = "9E09950B-47DE-4BAB-AA79-C29414312ECB", Name = "sample-name", Description = "sample-description", PictureUrl = "https://example.com/sample-picture.png", Calories = 1234, MealTypes = new[] { MealType.Snack }, Steps = new[] { "1. Sample first step.", "2. Sample second step." }, Ingredients = new[] { "Sample first ingredient", "Sample second ingredient" } }; eventStore.Verify(x => x.AddEvent(It.Is <RecipeUpdated>(y => y.WithDeepEqual(expected).Compare()))); }
public async Task ShouldRestoreRecipeCorrectly() { var request = new RestoreRecipe { EntityId = Guid.Parse("21552e39-3c5a-42e6-a116-e9f54643e57c") }; var handler = new RestoreRecipeHandler(_eventStore.Object, MockBuilder.BuildFakeRecipeEventsMapper(), MockBuilder.BuildFakeDateTimeService(), MockBuilder.BuildFakeCurrentUserService()); await handler.Handle(request, CancellationToken.None); var expected = new RecipeRestored { EntityId = Guid.Parse("21552e39-3c5a-42e6-a116-e9f54643e57c"), Published = new DateTime(2010, 1, 1), AuthorId = "edb4a387-260e-43c1-aed8-eec4dbd0fc31" }; _eventStore.Verify(x => x.AddEvent(It.Is <RecipeRestored>(y => y.WithDeepEqual(expected).Compare()))); }
public async void ShouldCreateRecipeCorrectly() { var command = new CreateRecipe { Name = "sample-name", Description = "sample-description", PictureUrl = "https://example.com/sample-image.png", Calories = 1234, MealTypes = new[] { MealType.Snack }, Steps = new[] { "1. Sample first step.", "2. Sample second step." }, Ingredients = new[] { "Sample first ingredient", "Sample second ingredient" } }; var eventStore = new Mock <IEventStore <Recipe> >(); var handler = new CreateRecipeHandler(eventStore.Object, MockBuilder.BuildFakeRecipeEventsMapper(), MockBuilder.BuildFakeCurrentUserService(), MockBuilder.BuildFakeDateTimeService()); await handler.Handle(command, CancellationToken.None); var expected = new RecipeCreated { EntityId = new Guid("7ADC9EF0-6A2A-4DE5-9C27-D4C2A4D9D5B6"), Published = new DateTime(2010, 1, 1), Version = 0, AuthorId = "9E09950B-47DE-4BAB-AA79-C29414312ECB", Name = "sample-name", Description = "sample-description", PictureUrl = "https://example.com/sample-image.png", Calories = 1234, MealTypes = new[] { MealType.Snack }, Steps = new[] { "1. Sample first step.", "2. Sample second step." }, Ingredients = new[] { "Sample first ingredient", "Sample second ingredient" } }; eventStore.Verify(x => x.AddEvent(It.Is <RecipeCreated>(y => y.WithDeepEqual(expected).IgnoreSourceProperty(z => z.EntityId).Compare() ))); }
public async void ShouldDeleteRecipeCorrectly() { // "62CB0EE2-0CF7-4C72-9C51-80A90E8E420E" - sample recipe id to delete var command = new DeleteRecipe(new Guid("62CB0EE2-0CF7-4C72-9C51-80A90E8E420E")); var eventStore = new Mock <IEventStore <Recipe> >(); var handler = new DeleteRecipeHandler(eventStore.Object, MockBuilder.BuildFakeRecipeEventsMapper(), MockBuilder.BuildFakeCurrentUserService(), MockBuilder.BuildFakeDateTimeService()); await handler.Handle(command, CancellationToken.None); var expected = new RecipeRemoved { EntityId = new Guid("62CB0EE2-0CF7-4C72-9C51-80A90E8E420E"), Version = 0, Published = new DateTime(2010, 1, 1), AuthorId = "9E09950B-47DE-4BAB-AA79-C29414312ECB" }; eventStore.Verify(x => x.AddEvent(It.Is <RecipeRemoved>(y => y.WithDeepEqual(expected).Compare()))); }