/// <summary> /// Initializes a new instance of the <see cref="ProductController" /> class. /// </summary> /// <param name="productService">The product service.</param> /// <param name="pricingService">The price service.</param> /// <param name="contentSearchHelper">The content search helper.</param> /// <param name="inventoryService">The inventory service.</param> public ProductController([NotNull] IProductService productService, [NotNull] IPricingService pricingService, ContentSearchHelper contentSearchHelper, [NotNull] IInventoryService inventoryService, [NotNull] ICatalogService catalogService) { this.productService = productService; this.pricingService = pricingService; this.contentSearchHelper = contentSearchHelper; this._inventoryService = inventoryService; this._catalogService = catalogService; this._obecContext = (CommerceContextBase)Factory.CreateObject(Constants.CommerceContext, true); }
public void ShouldReturnEmptyCollectionIfNoRenderingFound() { // Arrange var helper = new ContentSearchHelper(); using (var tree = new TTree()) { var item = tree.Database.GetItem("/sitecore/content/home"); // Act var query = helper.GetDataSourceQuery(item, new DeviceItem(item), ID.NewID.ToString()); // Assert query.Should().BeEmpty(); } }
/// <summary> /// Initializes a new instance of the <see cref="ProductControllerTest"/> class. /// </summary> public ProductControllerTest() { _context = new Glass.Sitecore.Mapper.Context(); GlassMapperService.Current = Substitute.For <Glass.Sitecore.Mapper.ISitecoreService>(); this.productService = Substitute.For <IProductService>(); this.pricingService = Substitute.For <IPricingService>(); this.contentSearchHelper = Substitute.For <ContentSearchHelper>(); this._inventoryService = Substitute.For <IInventoryService>(); this._catalogService = Substitute.For <ICatalogService>(); this._obecContext = Substitute.For <CommerceContextBase>(); var httpContext = Substitute.For <HttpContextBase>(); httpContext.Request.Url.Returns(new Uri("http://host/path")); httpContext.Request.QueryString.Returns(new NameValueCollection()); this.controller = new ProductController(this.productService, this.pricingService, this.contentSearchHelper, this._inventoryService, this._catalogService); this.controller.ControllerContext = new ControllerContext(httpContext, new RouteData(), this.controller); }