private static CustomerOrderServiceImpl GetCustomerOrderService() { Func <IPlatformRepository> platformRepositoryFactory = () => new PlatformRepository("VirtoCommerce", new EntityPrimaryKeyGeneratorInterceptor(), new AuditableInterceptor(null)); //var dynamicPropertyService = new DynamicPropertyService(platformRepositoryFactory); var dynamicPropertyService = new Mock <IDynamicPropertyService>().Object; var orderEventPublisher = new EventPublisher <OrderChangeEvent>(Enumerable.Empty <IObserver <OrderChangeEvent> >().ToArray()); var orderService = new CustomerOrderServiceImpl(GetOrderRepositoryFactory(), new TimeBasedNumberGeneratorImpl(), orderEventPublisher, dynamicPropertyService, GetShippingMethodsService(), GetPaymentMethodsService(), GetStoreService(), null, null); return(orderService); }
private static CustomerOrderServiceImpl GetCustomerOrderService() { Func <IPlatformRepository> platformRepositoryFactory = () => new PlatformRepository("VirtoCommerce", new EntityPrimaryKeyGeneratorInterceptor(), new AuditableInterceptor()); Func <ICartRepository> repositoryFactory = () => new CartRepositoryImpl("VirtoCommerce", new AuditableInterceptor()); var dynamicPropertyService = new DynamicPropertyService(platformRepositoryFactory); var orderEventPublisher = new EventPublisher <OrderChangeEvent>(Enumerable.Empty <IObserver <OrderChangeEvent> >().ToArray()); var cartEventPublisher = new EventPublisher <CartChangeEvent>(Enumerable.Empty <IObserver <CartChangeEvent> >().ToArray()); var cartService = new ShoppingCartServiceImpl(repositoryFactory, cartEventPublisher, null); var orderService = new CustomerOrderServiceImpl(GetOrderRepositoryFactory(), new TimeBasedNumberGeneratorImpl(), orderEventPublisher, cartService, null, dynamicPropertyService); return(orderService); }
private static OrderModuleController GetCustomerOrderController() { var mockInventory = new Mock <IInventoryService>(); Func <ICartRepository> repositoryFactory = () => { return(new CartRepositoryImpl("VirtoCommerce", new AuditableInterceptor())); }; var orderEventPublisher = new EventPublisher <OrderChangeEvent>(Enumerable.Empty <IObserver <OrderChangeEvent> >().ToArray()); var cartEventPublisher = new EventPublisher <CartChangeEvent>(Enumerable.Empty <IObserver <CartChangeEvent> >().ToArray()); var cartService = new ShoppingCartServiceImpl(repositoryFactory, cartEventPublisher, null); var orderService = new CustomerOrderServiceImpl(GetOrderRepositoryFactory(), new TimeBasedNumberGeneratorImpl(), orderEventPublisher, cartService, null); var controller = new OrderModuleController(orderService, null, null, new TimeBasedNumberGeneratorImpl(), null, null); return(controller); }
public void Can_search_by_OrganizationId() { //Arrange var mockRepository = new Moq.Mock <IOrderRepository>(); var sampleData = new List <CustomerOrderEntity>(new[] { new CustomerOrderEntity { Id = "1", OrganizationId = "myOrg1" }, new CustomerOrderEntity { Id = "2" } }); mockRepository.Setup(x => x.CustomerOrders).Returns(sampleData.AsQueryable()); mockRepository.Setup(x => x.GetCustomerOrdersByIds(It.IsAny <string[]>(), It.IsAny <CustomerOrderResponseGroup>())).Returns(new[] { sampleData.First() }); var orderService = new CustomerOrderServiceImpl(() => mockRepository.Object, null, null, null, null, null, null, null, new Moq.Mock <ICustomerOrderTotalsCalculator>().Object); //act var result = orderService.SearchCustomerOrders(new CustomerOrderSearchCriteria { OrganizationId = "myOrg1" }); //assert Assert.Single(result.Results, x => x.Id == "1"); Assert.Equal(1, result.TotalCount); }