public void Does_Map_Create_Recipe_Work_Correctly() { var dto = new CreateRecipe { Name = "Pizza Hawajska", Calories = 1200, Description = "Smaczna i zdrowa!", MealTypes = new[] { MealType.Snack, MealType.Lunch }, PictureUrl = "https://localhost:5001/img/pizza_hawajska.png", Steps = new[] { "Go into website and order it via phone!", "Wait for pizza boy to come and collect it from him." }, Ingredients = new[] { "1x Phone" } }; var entityId = Guid.Parse("be3dc63e-8f22-4d05-84b1-5fa6f4f652c4"); var expected = new RecipeCreated { EntityId = Guid.Parse("be3dc63e-8f22-4d05-84b1-5fa6f4f652c4"), Name = "Pizza Hawajska", Calories = 1200, Description = "Smaczna i zdrowa!", MealTypes = new[] { MealType.Snack, MealType.Lunch }, PictureUrl = "https://localhost:5001/img/pizza_hawajska.png", Steps = new[] { "Go into website and order it via phone!", "Wait for pizza boy to come and collect it from him." }, Ingredients = new[] { "1x Phone" }, AuthorId = "7f7dfc41-3b52-4c43-aef9-b82099a7beb2", Published = new DateTime(2020, 10, 10, 5, 2, 1), Version = 0 }; const string userId = "7f7dfc41-3b52-4c43-aef9-b82099a7beb2"; var date = new DateTime(2020, 10, 10, 5, 2, 1); var result = _mapper.Map(dto, entityId, date, userId); result.Should().BeEquivalentTo(expected); }
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() ))); }
private void When(RecipeCreated e) { Id = e.Id; }