コード例 #1
0
ファイル: ProjectionTests.cs プロジェクト: zamabraga/dflow
        public void ShouldUpdateProductCatalogView()
        {
            var rootId  = Guid.NewGuid();
            var handler = new ProductServiceCommandHandler(_eventStore, _factory);

            var idProd2 = Guid.NewGuid();
            var view    = new ProductView();

            _resolver.Register <ProductCreated>(view);

            IProductQueryHandler queryHandler = new ProductQueryHandler(view);

            handler.Execute(new CreateProductCatalog(rootId));
            handler.Execute(new CreateProductCommand(rootId, Guid.NewGuid(), "Notebook Lenovo 2 em 1 ideapad C340", "Notebook Lenovo 2 em 1 ideapad C340 i7-8565U 8GB 256GB SSD Win10 14' FHD IPS - 81RL0001BR"));
            handler.Execute(new CreateProductCommand(rootId, idProd2, "Notebook 2 em 1 Dell", "Notebook Lenovo 2 em 1 ideapad C340 i7-8565U 8GB 256GB SSD Win10 14' FHD IPS - 81RL0001BR"));

            var product      = queryHandler.GetById(idProd2);
            var listProducts = queryHandler.ListAllProducts();
            var dell         = queryHandler.ListByFilter(x => x.Name.Contains("Dell"));


            Assert.True(product.Id == idProd2);
            Assert.True(listProducts.Count == 2);
            Assert.True(dell.Count == 1);
        }
コード例 #2
0
        public void Init()
        {
            _productService = Substitute.For <IProductService>();
            _productService.GetProducts(Arg.Any <FilterDto>()).Returns(CreateMockProducts());
            _productService.GetProductById(Arg.Any <string>())
            .Returns(new Product
            {
                Id          = "MockId",
                Brand       = "Mock Brand",
                Description = "Mock Desc",
                Model       = "Mock Model"
            });

            _queryHandler = new ProductQueryHandler(_productService);
        }
コード例 #3
0
 public ProductController(ProductsCommandHandler commandHandler, ProductQueryHandler queryHandler)
 {
     this._commandHandler = commandHandler;
     this._queryHandler   = queryHandler;
 }