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);
        }
Exemplo n.º 2
0
        public async Task <Guid> Handle(CreateRecipe request, CancellationToken cancellationToken)
        {
            var @event = _mapper.Map(request, Guid.NewGuid(), _dateTime.GetCurrentTime(), _currentUser.GetUserId());
            await _eventStore.AddEvent(@event);

            return(@event.EntityId);
        }
        public async Task <Unit> Handle(DeleteRecipe request, CancellationToken cancellationToken)
        {
            var @event = _mapper.Map(request, _dateTime.GetCurrentTime(), _currentUser.GetUserId());
            await _eventStore.AddEvent(@event);

            return(Unit.Value);
        }