Ejemplo n.º 1
0
        public void Should_handle_query()
        {
            // arrange
            var category      = Fixture.Create <Category>();
            var otherCategory = Fixture.Create <Category>();
            var product       = Fixture.Create <Product>(x => x.Category = category);

            SaveAll(category, otherCategory, product);

            var command = new ProductEdit.Query
            {
                Id = product.Id
            };

            // act
            var result = Send(command);

            result.Name.ShouldBe(product.Name);
            result.Price.ShouldBe(product.Price);
            result.CategoryId.ShouldBe(product.CategoryId);
            result.Categories.Count().ShouldBe(2);
            result.Categories.At(0).DisplayName.ShouldContain(category.Name);
            result.Categories.At(1).DisplayName.ShouldContain(otherCategory.Name);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(ProductEdit.Query query)
        {
            var result = _mediator.Send(query);

            return(View("Edit", result));
        }