public OrderController(OrderServiceHandler orderServiceHandler, IConfiguration config, UserManager <CustomUser> userManager, ProductServiceHandler productServiceHandler)
 {
     _orderService          = orderServiceHandler;
     _productService        = productServiceHandler;
     this._userManager      = userManager;
     _orderServiceRootUrl   = config["OrderServiceURL"];
     this._cartName         = config["CartSessionCookie:Name"];
     _productServiceRootUrl = config["ProductServiceURL"];
 }
        public void MockRaise_WithIdIsAny_RaiseMyHandlerEvent()
        {
            var mockProductService = new Mock <IProductService>();
            var id        = Guid.NewGuid();
            var myHandler = new ProductServiceHandler(mockProductService.Object);

            System.Diagnostics.Debug.WriteLine($"This is {nameof(MockRaise_WithIdIsAny_RaiseMyHandlerEvent)} Id={id}");
            mockProductService.Setup(s => s.Repaire(It.IsAny <Guid>())).Verifiable();
            //这个注册的委托不会被调用,实际上是触发ProductServiceHandler中的Invoke委托
            mockProductService.Raise(s => s.MyHandlerEvent += null, new MyEventArgs(id));
            mockProductService.Object.Repaire(id);
        }
        public void MockSetupAddRemove_WithIdIsAny_RaiseMyHandlerEvent()
        {
            var mockProductService = new Mock <IProductService>();
            var id = Guid.NewGuid();

            mockProductService.SetupAdd(s => s.MyHandlerEvent    += It.IsAny <EventHandler>()).Verifiable();
            mockProductService.SetupRemove(s => s.MyHandlerEvent -= It.IsAny <EventHandler>()).Verifiable();

            var myHandler = new ProductServiceHandler(mockProductService.Object);

            mockProductService.VerifyAdd(s => s.MyHandlerEvent    += It.IsAny <EventHandler>(), Times.Once);
            mockProductService.VerifyRemove(s => s.MyHandlerEvent -= It.IsAny <EventHandler>(), Times.Never);
        }
 public ProductController(ProductServiceHandler productServiceHandler, IConfiguration config)
 {
     _productService        = productServiceHandler;
     _productServiceRootUrl = config["ProductServiceURL"];
 }
Exemple #5
0
 public ShoppingcartController(IConfiguration config, ProductServiceHandler productServiceHandler)
 {
     this._cartName = config["CartSessionCookie:Name"];
     this._productServiceHandler = productServiceHandler;
     _apiRootUrl = config.GetValue(typeof(string), "ProductServiceURL").ToString();
 }