Beispiel #1
0
        public void Admin_SaveCatalogSellerIdMismatch()
        {
            // Retrieve the catalog
            var context = new AmbientContext()
            {
                SellerId = 1, AuthToken = "MyToken"
            };
            var    managerFactory      = new ManagerFactory(context);
            var    adminCatalogManager = managerFactory.CreateManager <IAdminCatalogManager>();
            var    response            = adminCatalogManager.ShowCatalog(1);
            string responseJson        = StringUtilities.DataContractToJson(response);
            string expectedJson        = StringUtilities.DataContractToJson(AdminResponses.CatalogResponse);

            // Compare the response to a static representation of the response
            Assert.AreEqual(expectedJson, responseJson);

            // change the description and update the catalog
            response.Catalog.Description = "TEST_CATALOG updated description";
            // change the seller id in the context and recreate the manager
            managerFactory.Context.SellerId = 2;
            adminCatalogManager             = managerFactory.CreateManager <IAdminCatalogManager>();
            var updateResponse = adminCatalogManager.SaveCatalog(response.Catalog);

            responseJson = StringUtilities.DataContractToJson(updateResponse);
            expectedJson = StringUtilities.DataContractToJson(AdminResponses.CatalogSellerIdMismatchResponse);

            // Compare the update response to a static representation of the response
            Assert.AreEqual(expectedJson, responseJson);
        }
Beispiel #2
0
        public void Admin_SaveProductCatalogIdMismatch()
        {
            // Retrieve the product
            var context = new AmbientContext()
            {
                SellerId = 1, AuthToken = "MyToken"
            };
            var managerFactory      = new ManagerFactory(context);
            var adminCatalogManager = managerFactory.CreateManager <IAdminCatalogManager>();
            var response            = adminCatalogManager.ShowProduct(2, 1003);

            // normalize decimal percision - SQL Server and Sqlite behave differently
            response.Product.Price = response.Product.Price + 0.00M;

            string responseJson = StringUtilities.DataContractToJson(response);
            string expectedJson = StringUtilities.DataContractToJson(AdminResponses.ProductResponse);

            // Compare the response to a static representation of the response
            Assert.AreEqual(expectedJson, responseJson);

            // change the summary and update the product
            response.Product.Summary = "TEST_PRODUCT updated summary";
            // update the catalog id and recreate the manager
            adminCatalogManager = managerFactory.CreateManager <IAdminCatalogManager>();
            var updateResponse = adminCatalogManager.SaveProduct(3, response.Product);

            responseJson = StringUtilities.DataContractToJson(updateResponse);
            expectedJson = StringUtilities.DataContractToJson(AdminResponses.ProductCatalogIdMismtachResponse);

            // Compare the update response to a static representation of the response
            Assert.AreEqual(expectedJson, responseJson);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting Notifications Service");

            while (true)
            {
                var utilityFactory = new UtilityFactory(new AmbientContext());
                var asyncUtility   = utilityFactory.CreateUtility <IAsyncUtility>();
                var item           = asyncUtility.CheckForNewItem();
                if (item != null)
                {
                    // If the queued message contains a Context then pass it along instead of creating a new one
                    var managerFactory      = new ManagerFactory(item.AmbientContext ?? new AmbientContext());
                    var notificationManager = managerFactory.CreateManager <INotificationManager>();

                    if (item.EventType == AsyncEventTypes.OrderSubmitted)
                    {
                        notificationManager.SendNewOrderNotices(item.EventId);
                    }
                    if (item.EventType == AsyncEventTypes.OrderShipped)
                    {
                        notificationManager.SendOrderFulfillmentNotices(item.EventId);
                    }
                }

                Thread.Sleep(5000); // sleep 5 seconds
            }
        }
Beispiel #4
0
        protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequiredClaims requirement)
        {
            try
            {
                var userId             = context.User.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier");
                var managerFactory     = new ManagerFactory();
                var applicationManager = managerFactory.CreateManager <IApplicationManager>();
                var user            = applicationManager.GetUser(new System.Guid(userId.Value));
                var applicationName = Shared.Config.GetConfigValue("Name");
                var claims          = user.Applications.ToList().Where(app => app.ApplicationName == applicationName).Select(claim => claim.Claims).FirstOrDefault();

                bool hasAll = requirement.Claims.All(requirementClaim => claims.Any(claim => claim.ClaimType == requirementClaim.ClaimType && claim.ClaimValue == requirementClaim.ClaimValue));
                if (hasAll)
                {
                    context.Succeed(requirement);
                }

                return(Task.CompletedTask);
            }
            catch (Exception ex)
            {
                Logger.LogError("Error in HandleRequirementAsync", ex);
                throw ex;
            }
        }
Beispiel #5
0
        public bool PrepareMembers(List <string> filesToAdd)
        {
            int i = 0;

            result = ExitCodes.success;
            foreach (string file in filesToAdd)
            {
                string language = "lang" + (i++).ToString();
                CFileList.LanguageToFile.Add(language, file);
            }
            System.Console.WriteLine("Total files with localizations found: " + CFileList.LanguageToFile.Count.ToString());
            if (filesToAdd.Count < 2)
            {
                result = ExitCodes.noFiles;
                WaitForUser();
                return(false);
            }

            string tempfile = CFileList.LanguageToFile.Values.First();

            fileManager = ManagerFactory.CreateManager(InterfaceLocalizer.WorkMode.multilang, tempfile);
            System.Console.WriteLine("Created manager: " + fileManager.ToString());

            fileManager.AddFileToManager("emty arg");
            System.Console.WriteLine("Files added to manager");

            foreach (TroubleType type in Enum.GetValues(typeof(TroubleType)))
            {
                troubleDict.Add(type, 0);
            }
            return(true);
        }
Beispiel #6
0
        private IWebStoreCartManager GetWebStoreManager(Guid sessionId)
        {
            mockData.Context.SessionId = sessionId;
            ManagerFactory mgrFactory = new ManagerFactory(mockData.Context);

            return(mgrFactory.CreateManager <IWebStoreCartManager>(SetupMockEngineFactory(), SetupMockAccessorFactory(), null));
        }
Beispiel #7
0
        private static void ProductPriceCrawlFromFile()
        {
            // load the file
            using (StreamReader file = new StreamReader(@"Resources\products.csv"))
            {
                var factory = new ManagerFactory();
                var mgr     = factory.CreateManager <IPriceCrawlManager>();

                string textLine;
                // Loop until the end of file and call the operation for the line
                while ((textLine = file.ReadLine()) != null)
                {
                    string[] productParams = textLine.Split(',');
                    var      products      = mgr.GetProductPricingUsingSearch(productParams[2], productParams[1], productParams[0], false, _connString);

                    // Write out the results to the console window
                    foreach (Product product in products)
                    {
                        Console.WriteLine("{0}: {1} : {2}", product.Site, product.Price, product.ProductName);
                    }

                    Console.WriteLine();
                }
            }
        }
Beispiel #8
0
        private void MainForm_Activated(object sender, EventArgs e)
        {
            workMode        = (WorkMode)Properties.Settings.Default.WorkMode;
            currentFilelist = CFileList.GetProperList(workMode);
            currentManager  = ManagerFactory.CreateManager(workMode, currentFilelist.First());

            lMode.Text = Enum.GetName(typeof(WorkMode), workMode);
            gridViewTranslation.Columns["columnID"].IsVisible           = showInfo;
            gridViewTranslation.Columns["columnTags"].IsVisible         = showInfo;
            gridViewTranslation.Columns["columnFilename"].IsVisible     = showInfo;
            gridViewTranslation.Columns["columnTranslation2"].IsVisible = false;
            gridViewTranslation.Columns["columnTranslation3"].IsVisible = false;

            switch (workMode)
            {
            case WorkMode.interfaces:
                break;

            case  WorkMode.gossip:
                gridViewTranslation.Columns["columnID"].IsVisible       = false;
                gridViewTranslation.Columns["columnTags"].IsVisible     = false;
                gridViewTranslation.Columns["columnFilename"].IsVisible = false;
                break;

            case  WorkMode.multilang:
                for (int i = 0; i <= CFileList.LanguageToFile.Count(); i++)
                {
                    gridViewTranslation.Columns["columnTranslation" + i.ToString()].HeaderText = CFileList.LanguageToFile.Keys.ElementAt(i);
                    gridViewTranslation.Columns["columnTranslation" + i.ToString()].IsVisible  = true;
                }
                break;
            }
        }
        public void CheckManagerCreationExceptionTest()
        {
            var dateOfBirth = DateTime.Now.AddYears(-40);

            var sut = new ManagerFactory();

            Assert.Throws <InvalidManagerException>(() => sut.CreateManager("Jack", "", dateOfBirth));
        }
        public eCommerce.Contracts.Admin.Catalog.IAdminCatalogManager CreateAdminCatalogManager()
        {
            var factory = new ManagerFactory(mockData.Context);
            var manager = factory
                          .CreateManager <eCommerce.Contracts.Admin.Catalog.IAdminCatalogManager>(
                null, SetupMockAccessorFactory(), SetupMockUtilityFactory());

            return(manager);
        }
        protected override void CallManager()
        {
            var managerFactory     = new ManagerFactory(Context);
            var fulfillmentManager = managerFactory.CreateManager <IAdminFulfillmentManager>();

            var response = fulfillmentManager.FulfillOrder((Parameters[0] as IntUICommandParameter).Value);

            ShowResponse(response, response.Message);
        }
Beispiel #12
0
        protected override void CallManager()
        {
            var managerFactory         = new ManagerFactory(Context);
            var webStoreCatalogManager = managerFactory.CreateManager <IAdminCatalogManager>();

            var response = webStoreCatalogManager.FindCatalogs();

            ShowResponse(response, StringUtilities.DataContractToJson <WebStoreCatalog[]>(response.Catalogs));
        }
Beispiel #13
0
        protected override void CallManager()
        {
            var managerFactory    = new ManagerFactory(Context);
            var remittanceManager = managerFactory.CreateManager <IAdminRemittanceManager>();

            var response = remittanceManager.Totals();

            ShowResponse(response, $"OrderCount: {response.OrderCount}, OrderTotal: {response.OrderTotal}");
        }
Beispiel #14
0
        protected override void CallManager()
        {
            var managerFactory         = new ManagerFactory(Context);
            var webStoreCatalogManager = managerFactory.CreateManager <IAdminCatalogManager>();

            var catalogId = (Parameters[0] as IntUICommandParameter).Value;

            var response = webStoreCatalogManager.ShowCatalog(catalogId);

            ShowResponse(response, StringUtilities.DataContractToJson <WebStoreCatalog>(response.Catalog));
        }
Beispiel #15
0
        private static void RebuildSearch(int catalogId)
        {
            var context = new AmbientContext()
            {
                SellerId = 1
            };
            var managerFactory         = new ManagerFactory(context);
            var webStoreCatalogManager = managerFactory.CreateManager <Contracts.Admin.Catalog.IAdminCatalogManager>();

            webStoreCatalogManager.RebuildCatalog(catalogId);
        }
 public StatisticsForm(AppSettings _appSettings, WorkMode mode)
 {
     InitializeComponent();
     appSettings = _appSettings;
     fileList    = CFileList.GetProperList(mode);
     manager     = ManagerFactory.CreateManager(mode, fileList.First());
     foreach (TroubleType type in Enum.GetValues(typeof(TroubleType)))
     {
         troubleDict.Add(type, 0);
     }
 }
Beispiel #17
0
        private static void UpdateShippingInfo(Address shippingAddress, bool billingSameAsShipping, Guid sessionId)
        {
            var context = new AmbientContext()
            {
                SellerId = 1, SessionId = sessionId
            };
            var managerFactory      = new ManagerFactory(context);
            var webStoreCartManager = managerFactory.CreateManager <IWebStoreCartManager>();
            var response            = webStoreCartManager.UpdateShippingInfo(1, shippingAddress, billingSameAsShipping);

            ShowResponse(response, StringUtilities.DataContractToJson <WebStoreCart>(response.Cart));
        }
Beispiel #18
0
        private static void SubmitOrder(Guid sessionId)
        {
            var context = new AmbientContext()
            {
                SellerId = 1, SessionId = sessionId
            };
            var managerFactory       = new ManagerFactory(context);
            var webStoreOrderManager = managerFactory.CreateManager <IWebStoreOrderManager>();
            var response             = webStoreOrderManager.SubmitOrder(1, PaymentInstrument);

            ShowResponse(response, StringUtilities.DataContractToJson <WebStoreOrder>(response.Order));
        }
Beispiel #19
0
        private static void ShowCart(Guid sessionId)
        {
            var context = new AmbientContext()
            {
                SellerId = 1, SessionId = sessionId
            };
            var managerFactory      = new ManagerFactory(context);
            var webStoreCartManager = managerFactory.CreateManager <IWebStoreCartManager>();
            var response            = webStoreCartManager.ShowCart(1);

            ShowResponse(response, StringUtilities.DataContractToJson <WebStoreCart>(response.Cart));
        }
Beispiel #20
0
        private static void RemoveItemFromCart(int productId, Guid sessionId)
        {
            var context = new AmbientContext()
            {
                SellerId = 1, SessionId = sessionId
            };
            var managerFactory      = new ManagerFactory(context);
            var webStoreCartManager = managerFactory.CreateManager <IWebStoreCartManager>();
            var response            = webStoreCartManager.RemoveCartItem(1, productId);

            ShowResponse(response, StringUtilities.DataContractToJson <WebStoreCart>(response.Cart));
        }
Beispiel #21
0
        private static void ShowProductDetail(int catalogId, int productId)
        {
            var context = new AmbientContext()
            {
                SellerId = 1
            };
            var managerFactory         = new ManagerFactory(context);
            var webStoreCatalogManager = managerFactory.CreateManager <IWebStoreCatalogManager>();
            var response = webStoreCatalogManager.ShowProduct(catalogId, productId);

            ShowResponse(response, StringUtilities.DataContractToJson <ProductDetail>(response.Product));
        }
Beispiel #22
0
        private static void ShowCatalog(int catalogId)
        {
            var context = new AmbientContext()
            {
                SellerId = 1
            };
            var managerFactory         = new ManagerFactory(context);
            var webStoreCatalogManager = managerFactory.CreateManager <IWebStoreCatalogManager>();
            var response = webStoreCatalogManager.ShowCatalog(catalogId);

            ShowResponse(response, StringUtilities.DataContractToJson <WebStoreCatalog>(response.Catalog));
        }
        private IAdminFulfillmentManager GetFulfillmentManager(string authToken)
        {
            this.mockData.Context = new AmbientContext()
            {
                AuthToken = authToken,
                SessionId = Guid.NewGuid(),
                SellerId  = 1
            };
            ManagerFactory mgrFactory = new ManagerFactory(this.mockData.Context);

            return(mgrFactory.CreateManager <IAdminFulfillmentManager>(null, SetupMockAccessorFactory(), SetupMockUtilityFactory()));
        }
Beispiel #24
0
        private T GetManager <T>(AmbientContext context) where T : class
        {
            // replace the AsyncUtility with a mock to avoid usage of queue IFX in tests
            var mockAsyncUtility = new MockAsyncUtility(this.mockData);

            UtilityFactory utilFactory = new UtilityFactory(context);

            utilFactory.AddOverride <IAsyncUtility>(mockAsyncUtility);

            var managerFactory = new ManagerFactory(context);

            return(managerFactory.CreateManager <T>(null, null, utilFactory));
        }
        private IWebStoreOrderManager GetWebStoreManager(Guid sessionId)
        {
            mockData         = new MockData();
            mockData.Context = new AmbientContext()
            {
                AuthToken = "",
                SessionId = sessionId
            };

            ManagerFactory mgrFactory = new ManagerFactory(mockData.Context);

            return(mgrFactory.CreateManager <IWebStoreOrderManager>(null, SetupMockAccessorFactory(), SetupMockUtilityFactory()));
        }
        public void AddApplication_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var    managerFactory  = new ManagerFactory();
            var    manager         = managerFactory.CreateManager <IApplicationManager>();
            string applicationName = Guid.NewGuid().ToString();

            // Act
            var result = manager.AddApplication(applicationName);

            // Assert
            Assert.NotNull(result);
        }
Beispiel #27
0
        public void Admin_ShowProductNoAuth()
        {
            var context = new AmbientContext()
            {
                SellerId = 1, AuthToken = ""
            };
            var    managerFactory         = new ManagerFactory(context);
            var    webStoreCatalogManager = managerFactory.CreateManager <IAdminCatalogManager>();
            var    response     = webStoreCatalogManager.ShowProduct(1, 1);
            string responseJson = StringUtilities.DataContractToJson(response);
            string expectedJson = StringUtilities.DataContractToJson(AdminResponses.ProductNoAuthResponse);

            Assert.AreEqual(expectedJson, responseJson);
        }
Beispiel #28
0
        protected override void CallManager()
        {
            var badContext = new AmbientContext()
            {
                SellerId  = Context.SellerId,
                AuthToken = null
            };
            var managerFactory         = new ManagerFactory(badContext);
            var webStoreCatalogManager = managerFactory.CreateManager <IAdminCatalogManager>();

            var response = webStoreCatalogManager.FindCatalogs();

            ShowResponse(response, StringUtilities.DataContractToJson <WebStoreCatalog[]>(response.Catalogs));
        }
        protected override void CallManager()
        {
            var managerFactory         = new ManagerFactory(Context);
            var webStoreCatalogManager = managerFactory.CreateManager <IAdminCatalogManager>();

            var catalog = new WebStoreCatalog()
            {
                Name        = (Parameters[0] as StringUICommandParameter).Value,
                Description = "new catalog"
            };
            var response = webStoreCatalogManager.SaveCatalog(catalog);

            ShowResponse(response, StringUtilities.DataContractToJson <WebStoreCatalog>(response.Catalog));
        }
Beispiel #30
0
        private static void ProductPriceCrawl(string brand, string productCode, string industryCode)
        {
            var factory = new ManagerFactory();
            var mgr     = factory.CreateManager <IPriceCrawlManager>();

            var products = mgr.GetProductPricingUsingSearch(brand, productCode, industryCode, false, _connString);

            // Write out the results to the console window
            foreach (Product product in products)
            {
                Console.WriteLine("{0}: {1} : {2}", product.Site, product.Price, product.ProductName);
            }

            Console.WriteLine();
        }