/// <summary>
 /// Initializes a new instance of the <see cref="ProductOptionApiController"/> class.
 /// </summary>
 /// <param name="merchelloContext">
 /// The merchello context.
 /// </param>
 /// <param name="contentTypeService">
 /// Umbraco's <see cref="IContentTypeService"/>
 /// </param>
 public ProductOptionApiController(IMerchelloContext merchelloContext, IContentTypeService contentTypeService)
     : base(merchelloContext)
 {
     Mandate.ParameterNotNull(contentTypeService, "contentTypeService");
     _contentTypeService = contentTypeService;
     _productOptionService = merchelloContext.Services.ProductOptionService;
 }
Exemple #2
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            this._merchello = new MerchelloHelper();

            this._productOptionService = MerchelloContext.Current.Services.ProductOptionService;

            this._productService = MerchelloContext.Current.Services.ProductService;

            this.DbPreTestDataWorker.DeleteAllProducts();
            this.DbPreTestDataWorker.DeleteAllSharedOptions();

            var option = CreateSavedOption();

            _optionKey = option.Key;

            var product1 = CreateSavedProduct();

            this._product1Key = product1.Key;

            var product2 = DbPreTestDataWorker.MakeExistingProduct();
            product2.ProductOptions.Add(new ProductOption("Size"));
            product2.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Small", "sm"));
            product2.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Medium", "md"));
            product2.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Large", "lg"));

            DbPreTestDataWorker.ProductService.Save(product2);

            _product2Key = product2.Key;

            MerchelloContext.Current.Cache.RuntimeCache.ClearAllCache();
        }
Exemple #3
0
 public void Init()
 {
     _fixture = new Fixture();
     _fixture.Behaviors.Remove(new ThrowingRecursionBehavior());
     _fixture.Behaviors.Add(new OmitOnRecursionBehavior());
     _productRepo          = new Mock <IProductRepository>();
     _productOptionRepo    = new Mock <IProductOptionRepository>();
     _productOptionService = new ProductOptionService(_productOptionRepo.Object, _productRepo.Object);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductsController"/> class.
 /// </summary>
 /// <param name="productService">The product service.</param>
 /// <param name="productOptionService">The product option service.</param>
 public ProductsController(
     IProductService productService,
     IProductOptionService productOptionService,
     ILoggingService loggingService)
 {
     _productService       = productService;
     _productOptionService = productOptionService;
     _loggingService       = loggingService;
 }
Exemple #5
0
 public ProductsController(IUnitOfWork aUnitOfWork,
                           IProductService aProductService,
                           IProductOptionService aProductOptionService,
                           IMapper aMapper)
 {
     _aUnitOfWork           = aUnitOfWork;
     _aProductService       = aProductService;
     _aProductOptionService = aProductOptionService;
     _aMapper = aMapper;
 }
Exemple #6
0
 public ProductsController(IProductService productService, IProductOptionService productOptionService)
 {
     if (productService == null)
     {
         throw new ArgumentNullException(nameof(productService));
     }
     if (productOptionService == null)
     {
         throw new ArgumentNullException(nameof(productOptionService));
     }
     _productService       = productService;
     _productOptionService = productOptionService;
 }
        protected void ConfigTest()
        {
            _testProductOptionModel = new ProductOptionModel()
            {
                Id          = new Guid("8F2E0176-35EE-4F0A-AE55-83023DDDB1A3"),
                Name        = "TestName",
                Description = "TestDescription",
                ProductId   = new Guid("8F2E0176-35EE-4F0A-AE55-83023D2DB1A3"),
            };
            _testProductOptionModel0 = new ProductOptionModel()
            {
                Id          = new Guid("8F2E0175-35EE-4F0A-AE55-83023D2DB1A3"),
                Name        = "TestName0",
                Description = "TestDescription0",
                ProductId   = new Guid("8F2E0176-35EE-4F0A-AE55-83023D2DB1A3"),
            };

            _testProductOption = new ProductOption()
            {
                Id          = new Guid("8F2E0176-35EE-4F0A-AE55-83023DDDB1A3"),
                Name        = "TestName",
                Description = "TestDescription",
                ProductId   = new Guid("8F2E0176-35EE-4F0A-AE55-83023D2DB1A3"),
            };
            _testProductOption0 = new ProductOption()
            {
                Id          = new Guid("8F2E0175-35EE-4F0A-AE55-83023D2DB1A3"),
                Name        = "TestName0",
                Description = "TestDescription0",
                ProductId   = new Guid("8F2E0176-35EE-4F0A-AE55-83023D2DB1A3"),
            };

            _testProduct = new Product()
            {
                Id             = new Guid("8F2E0176-35EE-4F0A-AE55-83023D2DB1A3"),
                Name           = "TestName",
                Description    = "TestDescription",
                Price          = 1.01m,
                DeliveryPrice  = 2.02m,
                ProductOptions = new List <ProductOption>(),
            };

            _helper._mockProductTable.Add(_testProduct);
            _testService = new ProductOptionService(_helper._mockUnitOfwork.Object);
        }
        public void Initialize()
        {
            //Arrange for Tests
            var mapperConfig = new MapperConfiguration(cnfig =>
            {
                cnfig.AddProfile(new RepositoryMapper());
            });

            _mapper = mapperConfig.CreateMapper();

            _mockContext = new FakeDatabaseEntitiesContext
            {
                Products =
                {
                    new data.Product {
                        Id = new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"), Name = "Samsung Galaxy S7", Description = "Newest mobile product from Samsung.", Price = 1024.99M, DeliveryPrice = 16.99M
                    },
                    new data.Product {
                        Id = new Guid("de1287c0-4b15-4a7b-9d8a-dd21b3cafec3"), Name = "Apple iPhone 6S", Description = "Newest mobile product from Apple.", Price = 1299.99M, DeliveryPrice = 15.99M
                    }
                },
                ProductOptions =
                {
                    new data.ProductOption {
                        Id = new Guid("0643ccf0-ab00-4862-b3c5-40e2731abcc9"), ProductId = new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"), Name = "White", Description = "White Samsung Galaxy S7"
                    },
                    new data.ProductOption {
                        Id = new Guid("a21d5777-a655-4020-b431-624bb331e9a2"), ProductId = new Guid("8f2e9176-35ee-4f0a-ae55-83023d2db1a3"), Name = "Black", Description = "Black Samsung Galaxy S7"
                    },
                    new data.ProductOption {
                        Id = new Guid("5c2996ab-54ad-4999-92d2-89245682d534"), ProductId = new Guid("de1287c0-4b15-4a7b-9d8a-dd21b3cafec3"), Name = "Rose Gold", Description = "Gold Apple iPhone 6S"
                    }
                }
            };
            _logging = new LoggingService();
            var productOptionRepository = new ProductOptionRepository(_mapper, _mockContext, _logging);
            var productRepository       = new ProductRepository(_mapper, _mockContext, _logging);

            _productOptionService = new ProductOptionService(productOptionRepository);
        }
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            this._merchello = new MerchelloHelper();

            this._productOptionService = MerchelloContext.Current.Services.ProductOptionService;

            this._productService = MerchelloContext.Current.Services.ProductService;

            this.DbPreTestDataWorker.DeleteAllProducts();
            this.DbPreTestDataWorker.DeleteAllSharedOptions();

            var option = CreateSavedOption();

            _optionKey = option.Key;


            var product1 = CreateSavedProduct();

            this._product1Key = product1.Key;


            var product2 = DbPreTestDataWorker.MakeExistingProduct();

            product2.ProductOptions.Add(new ProductOption("Size"));
            product2.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Small", "sm"));
            product2.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Medium", "md"));
            product2.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Large", "lg"));

            DbPreTestDataWorker.ProductService.Save(product2);

            _product2Key = product2.Key;

            MerchelloContext.Current.Cache.RuntimeCache.ClearAllCache();
        }
 public ProductsController(IProductService productService, IProductOptionService productOptionService)
 {
     this.productService       = productService;
     this.productOptionService = productOptionService;
 }
 public ProductOptionsController(IProductOptionService productOptionService)
 {
     this._productOptionService = productOptionService;
 }
Exemple #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="productService"></param>
 public ProductOptionController(ILogger <ProductOptionController> logger,
                                IProductOptionService productService)
 {
     _logger = logger;
     _productOptionService = productService;
 }
Exemple #13
0
 public ProductService(IProductRepository productRepository, IProductOptionService productOptionService)
 {
     _productRepository    = productRepository;
     _productOptionService = productOptionService;
 }
 public ProductOptionsController(IProductOptionService service)
 {
     _productOptionservice = service;
 }
 public ProductOptionsController(IProductService productService, IProductOptionService productOptionService, IMapper mapper)
 {
     _productService       = productService;
     _productOptionService = productOptionService;
     _mapper = mapper;
 }
Exemple #16
0
 public ProductOptionAppService(IProductOptionService productOptionService, IUnitOfWork unitOfWork)
     : base(unitOfWork)
 {
     this._productOptionService = productOptionService;
 }
Exemple #17
0
 public ProductOptionsController(IProductOptionService productOptionService,
                                 ILogger logger)
 {
     _productOptionService = productOptionService;
     _logger = logger;
 }
Exemple #18
0
 public ProductOptionsController(IProductService productService, IProductOptionService productOptionService)
 {
     _productService       = productService;
     _productOptionService = productOptionService;
 }
Exemple #19
0
 public void SetUp()
 {
     AppDomain.CurrentDomain.SetData("DataDirectory", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
     _productsOptionService = new ProductOptionService();
     _productsService       = new ProductService();
 }
Exemple #20
0
 public void DisposeTest()
 {
     _productsService       = null;
     _productsOptionService = null;
 }