/// <summary>
 /// This is a helper contructor for unit testing
 /// </summary>
 internal ProductVariantApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
     : base(merchelloContext, umbracoContext)
 {
     _productService = MerchelloContext.Services.ProductService;
     _productVariantService = MerchelloContext.Services.ProductVariantService;
     _warehouseService = MerchelloContext.Services.WarehouseService;
 }
        public virtual void FixtureSetup()
        {
            var serviceContext = new ServiceContext(new PetaPocoUnitOfWorkProvider());

            _dbPreTestDataWorker = new DbPreTestDataWorker(serviceContext);

            if (!GatewayProviderResolver.HasCurrent)
            GatewayProviderResolver.Current = new GatewayProviderResolver(
            PluginManager.Current.ResolveGatewayProviders(),
            serviceContext.GatewayProviderService,
            new NullCacheProvider());

            MerchelloContext = new MerchelloContext(serviceContext,
                new GatewayContext(serviceContext, GatewayProviderResolver.Current),
                new CacheHelper(new NullCacheProvider(),
                                    new NullCacheProvider(),
                                    new NullCacheProvider()));

            if (!TriggerResolver.HasCurrent)
                TriggerResolver.Current = new TriggerResolver(PluginManager.Current.ResolveObservableTriggers());

            if (!MonitorResolver.HasCurrent)
                MonitorResolver.Current = new MonitorResolver(MerchelloContext.Gateways.Notification, PluginManager.Current.ResolveObserverMonitors());

            AutoMapperMappings.CreateMappings();
            ExamineManager.Instance.IndexProviderCollection["MerchelloProductIndexer"].RebuildIndex();
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="merchelloContext"></param>
 public CatalogFixedRateShippingApiController(MerchelloContext merchelloContext)
     : base(merchelloContext)
 {
     _shipCountryService = ((ServiceContext) MerchelloContext.Services).ShipCountryService;
     _fixedRateShippingGatewayProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Gateways.Shipping.GetProviderByKey(Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey);
     _shippingContext = MerchelloContext.Gateways.Shipping;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="merchelloContext"></param>
 public ProductVariantApiController(MerchelloContext merchelloContext)
     : base(merchelloContext)
 {
     _productService = MerchelloContext.Services.ProductService;
     _productVariantService = MerchelloContext.Services.ProductVariantService;
     _warehouseService = MerchelloContext.Services.WarehouseService;
 }
 /// <summary>
 /// This is a helper contructor for unit testing
 /// </summary>
 internal CatalogShippingApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
     : base(merchelloContext, umbracoContext)
 {
     _gatewayProviderService = MerchelloContext.Services.GatewayProviderService;
     _storeSettingService = MerchelloContext.Services.StoreSettingService;
     _shipCountryService = ((ServiceContext)MerchelloContext.Services).ShipCountryService;
 }
Ejemplo n.º 6
0
        protected MerchelloApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
            : base(umbracoContext)
        {
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");

            MerchelloContext = merchelloContext;
            InstanceId = Guid.NewGuid();
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="merchelloContext"></param>
        public ShippingGatewayApiController(MerchelloContext merchelloContext)
            : base(merchelloContext)
        {
            _shippingContext = MerchelloContext.Gateways.Shipping;

            _gatewayProviderService = MerchelloContext.Services.GatewayProviderService;
            _storeSettingService = MerchelloContext.Services.StoreSettingService;
            _shipCountryService = ((ServiceContext)MerchelloContext.Services).ShipCountryService;
        }
Ejemplo n.º 8
0
		public void GetCustomerThrowsWhenRepositoryReturnsNull()
		{
			// Arrange
			Guid customerKey = Guid.NewGuid();

			var MockCustomerService = new Mock<ICustomerService>();
			MockCustomerService.Setup(cs => cs.GetById(customerKey)).Returns((AnonymousCustomer)null);

			var MockServiceContext = new Mock<IServiceContext>();
			MockServiceContext.SetupGet(sc => sc.CustomerService).Returns(MockCustomerService.Object);

			MerchelloContext merchelloContext = new MerchelloContext(MockServiceContext.Object);

			CustomerApiController ctrl = new CustomerApiController(merchelloContext, tempUmbracoContext);

			var ex = Assert.Throws<HttpResponseException>(() => ctrl.GetCustomer(Guid.Empty));
		}
 /// <summary>
 /// This is a helper contructor for unit testing
 /// </summary>
 internal CatalogFixedRateShippingApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
     : base(merchelloContext, umbracoContext)
 {
     _shipCountryService = ((ServiceContext)MerchelloContext.Services).ShipCountryService;
     _fixedRateShippingGatewayProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Gateways.Shipping.CreateInstance(Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param>
 public PaymentGatewayApiController(MerchelloContext merchelloContext)
     : base(merchelloContext)
 {
     _paymentContext = MerchelloContext.Gateways.Payment;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// This is a helper contructor for unit testing
 /// </summary>
 internal SettingsApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
     : base(merchelloContext, umbracoContext)
 {
     _storeSettingService = MerchelloContext.Services.StoreSettingService as StoreSettingService;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="merchelloContext"></param>
 public SettingsApiController(MerchelloContext merchelloContext)
     : base(merchelloContext)
 {
     _storeSettingService = MerchelloContext.Services.StoreSettingService as StoreSettingService;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// This is a helper contructor for unit testing
 /// </summary>
 internal WarehouseApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
     : base(merchelloContext, umbracoContext)
 {
     _warehouseService = MerchelloContext.Services.WarehouseService;
 }
Ejemplo n.º 14
0
 /// <summary>
 /// This is a helper contructor for unit testing
 /// </summary>
 internal CustomerApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
     : base(merchelloContext, umbracoContext)
 {
     _customerService = MerchelloContext.Services.CustomerService;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param>
 public NotificationGatewayApiController(MerchelloContext merchelloContext)
     : base(merchelloContext)
 {
     _notificationContext = ((GatewayContext)MerchelloContext.Gateways).Notification;
 }
Ejemplo n.º 16
0
        public void GetInvoiceThrowsWhenRepositoryReturnsNull()
        {
            // Arrange
            int id = 1;

            var MockInvoiceService = new Mock<IInvoiceService>();
            MockInvoiceService.Setup(cs => cs.GetById(id)).Returns((Invoice)null);

            var MockServiceContext = new Mock<IServiceContext>();
            MockServiceContext.SetupGet(sc => sc.InvoiceService).Returns(MockInvoiceService.Object);

            MerchelloContext merchelloContext = new MerchelloContext(MockServiceContext.Object);

            InvoiceApiController ctrl = new InvoiceApiController(merchelloContext, tempUmbracoContext);

            var ex = Assert.Throws<HttpResponseException>(() => ctrl.GetInvoiceById(0));
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="merchelloContext"></param>
 public ScheduledTasksApiController(MerchelloContext merchelloContext)
     : base()
 {
     _anonymousCustomerService = ((ServiceContext)merchelloContext.Services).AnonymousCustomerService;
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates the MerchelloPluginContext (singleton)
        /// </summary>
        /// <param name="serviceContext">The service context</param>
        /// <param name="cache">The cache helper</param>
        /// <remarks>
        /// Since we load fire our boot manager after Umbraco fires its "started" even, Merchello gets the benefit
        /// of allowing Umbraco to manage the various caching providers via the Umbraco CoreBootManager or WebBootManager
        /// depending on the context.
        /// </remarks>
        protected void CreateMerchelloContext(ServiceContext serviceContext, CacheHelper cache)
        {
            var gateways = new GatewayContext(serviceContext, GatewayProviderResolver.Current);

            _merchelloContext = MerchelloContext.Current = new MerchelloContext(serviceContext, gateways, cache);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Creates the MerchelloPluginContext (singleton)
        /// </summary>
        /// <param name="serviceContext"></param>
        /// <remarks>
        /// Since we load fire our boot manager after Umbraco fires its "started" even, Merchello gets the benefit
        /// of allowing Umbraco to manage the various caching providers via the Umbraco CoreBootManager or WebBootManager
        /// depending on the context.
        /// </remarks>
        protected void CreateMerchelloContext(ServiceContext serviceContext)
        {
            // TODO: Mock the ApplicationContext.  ApplicationContext should never be null but we need this for unit testing at this point
            var cache = ApplicationContext.Current == null
                            ? new CacheHelper(
                                    new ObjectCacheRuntimeCacheProvider(),
                                    new StaticCacheProvider(),
                                    new NullCacheProvider())
                            : ApplicationContext.Current.ApplicationCache;

            MerchelloContext = MerchelloContext.Current = new MerchelloContext(serviceContext, cache, _isTest);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Creates the MerchelloPluginContext (singleton)
 /// </summary>
 /// <param name="serviceContext">The service context</param>
 /// <param name="cache">The cache helper</param>
 /// <remarks>
 /// Since we load fire our boot manager after Umbraco fires its "started" even, Merchello gets the benefit
 /// of allowing Umbraco to manage the various caching providers via the Umbraco CoreBootManager or WebBootManager
 /// depending on the context.
 /// </remarks>
 protected void CreateMerchelloContext(ServiceContext serviceContext, CacheHelper cache)
 {
     var gateways = new GatewayContext(serviceContext, GatewayProviderResolver.Current);
     _merchelloContext = MerchelloContext.Current = new MerchelloContext(serviceContext, gateways, cache);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="merchelloContext"></param>
 public WarehouseApiController(MerchelloContext merchelloContext)
     : base(merchelloContext)
 {
     _warehouseService = MerchelloContext.Services.WarehouseService;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param>
 public TaxationGatewayApiController(MerchelloContext merchelloContext)
     : base(merchelloContext)
 {
     _taxationContext = MerchelloContext.Gateways.Taxation;
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="merchelloContext"></param>
 public CustomerApiController(MerchelloContext merchelloContext)
     : base(merchelloContext)
 {
     _customerService = MerchelloContext.Services.CustomerService;
 }