コード例 #1
0
        public void TestUpdateCurrentSalonSettings()
        {
            test = new GiftCardMSSQLDAO();
            var salon = createTestCompanyModel();

            Assert.IsTrue(test.UpdateSalon(salon));
            var img     = loadImage();
            var logo_id = test.SaveUploadedFile(new UploadedFile()
            {
                CompanyId  = salon.Id.Value,
                FileLength = img.Length,
                FileName   = "mylogo.jpg"
            });
            var input = new CurrentCompanyDisplaySettings()
            {
                CompanyId        = salon.Id,
                CurrentThemeName = "Test theme"
            };
            var ret = test.UpdateCompanySettings(input, logo_id.Value);

            Assert.IsNotNull(ret);

            input.CurrentThemeName = "Test theme 2";
            ret = test.UpdateCompanySettings(input, logo_id.Value);
            Assert.IsNotNull(ret);
            var result = test.RetrieveDisplaySettings(salon.Id.Value);
        }
コード例 #2
0
        public void TestCreateProductForCategoryBySalon()
        {
            test = new GiftCardMSSQLDAO();
            var salon = createTestCompanyModel();

            Assert.IsTrue(test.UpdateSalon(salon));
            var category = "test" + (DateTime.Now.Millisecond % 100);
            var ret      = test.CreateCategoryForCompany(salon.Id.Value, category);

            Assert.IsTrue(ret.HasValue);
            String p = "Product_" + (DateTime.Now.Millisecond % 90) + "_";
            var    r = new Random();

            for (int t = 0; t < 5; t++)
            {
                var ret2 = test.CreateProductForCategoryByCompany(ret.Value, p + t, ((((int)(r.NextDouble() * 10000)) / 100)));
                Assert.IsTrue(ret2.HasValue);
            }
            var results = test.RetrieveProductsBySalonCategory(ret.Value);

            Assert.IsNotNull(results);
            Assert.AreEqual(5, results.Count);
            Assert.AreEqual(p + 3, results[3].Name);
            Assert.IsNotNull(results[4].ProductId);
        }
コード例 #3
0
        public void TestUpdateSalon()
        {
            test = new GiftCardMSSQLDAO();
            var salon = createTestCompanyModel();

            Assert.IsTrue(test.UpdateSalon(salon));
            var testsalon = test.retrieveClients();

            Assert.IsTrue(testsalon.Count > 0);
            var foundsalon = testsalon.Find(i => i.CompanyName.Equals(salon.CompanyName));

            Assert.IsNotNull(foundsalon);
            Assert.AreEqual <String>(foundsalon.CompanyAddress.AddressOne, salon.CompanyAddress.AddressOne);
            Assert.IsTrue(salon.Id.HasValue);
        }
コード例 #4
0
        public void TestCreateCategoryForSalon()
        {
            test = new GiftCardMSSQLDAO();
            var salon = createTestCompanyModel();

            Assert.IsTrue(test.UpdateSalon(salon));
            var t   = "test" + (DateTime.Now.Millisecond % 100);
            var ret = test.CreateCategoryForCompany(salon.Id.Value, t);

            Assert.IsTrue(ret.HasValue);
            var results = test.RetrieveCategoriesByCompany(salon.Id.Value);

            Assert.IsNotNull(results);
            Assert.IsNotNull(results.Find(item => item.Trim() == t));
        }
コード例 #5
0
        public void TestInputPendingOrder()
        {
            test = new GiftCardMSSQLDAO().Init();
            var salon = createTestCompanyModel();
            var input = createTestPendingOrder(salon);

            Assert.IsTrue(test.UpdateSalon(salon));
            input.CompanyId = salon.Id.Value;
            var s = test.InsertPendingOrder(input);

            Assert.IsTrue(s.HasValue);
            var results = test.retrievePendingOrders(salon.Id.Value, DateTime.Now.AddMinutes(-3), DateTime.Now.AddMinutes(2));

            Assert.IsNotNull(results);
            Console.WriteLine("Number returned is " + results.Count);
            Assert.IsTrue(results.Count > 0);
        }
コード例 #6
0
        public void TestSaveUploadedFile()
        {
            test = new GiftCardMSSQLDAO();
            var salon = createTestCompanyModel();

            Assert.IsTrue(test.UpdateSalon(salon));
            var img   = loadImage();
            var input = new UploadedFile()
            {
                FileLength = img.Length,
                FileName   = "mylogo.jpg"
            };
            var logo_id = test.SaveUploadedFile(input);

            Assert.IsNotNull(logo_id);
            Assert.IsTrue(logo_id.HasValue);
            var result = test.RetrieveLogoFileInfoForClient(salon.Id.Value);

            Assert.IsNotNull(result);
            Assert.AreEqual(input.FileLength, result.FileLength);
            Assert.AreEqual(input.FileName, result.FileName);
        }
コード例 #7
0
        public void TestSaveAuthInfo()
        {
            test = new GiftCardMSSQLDAO();
            var salon = createTestCompanyModel();

            Assert.IsTrue(test.UpdateSalon(salon));
            var testsalon = test.retrieveClients();

            Assert.IsTrue(testsalon.Count > 0);
            var    foundsalon = testsalon.Find(i => i.CompanyName.Equals(salon.CompanyName));
            string username   = "******" + DateTime.Now.Second;
            string password   = "******" + DateTime.Now.Millisecond;
            var    enc        = Encoding.Default;
            SHA256 mySHA256   = SHA256Managed.Create();

            Assert.IsTrue(test.SaveAuthInfo(foundsalon.Id.Value, username, mySHA256.ComputeHash(enc.GetBytes(password))));
            var hash = mySHA256.ComputeHash(enc.GetBytes(password));
            var d    = test.CheckPassword(foundsalon.Id.Value, username, hash);

            Assert.IsNotNull(d);
            Assert.IsTrue(d, "SELECT password_len FROM AuthInfo WHERE salon_id=" + foundsalon.Id.Value + " AND username='******'\n AND password=" + Convert.ToBase64String(hash));
        }