Example #1
0
        public void TestAddOrderedCoupon()
        {
            using (basicEntities be = new basicEntities())
            {
                owner    = TestOwner.AddOwner("owner123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
                admin    = TestAdmin.AddAdmin("admin123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
                b        = TestBusiness.AddBusinesses("123", admin, owner, "beer-Sheva", "bla", Category.CarsAccessories);
                cop      = TestCoupon.CreateCoupon(2, "Fly PIZZA", "100", "40", b, "10/10/2014", 8);
                customer = TestCustomer.AddCustomer("Customer123", "adam", "admin123123", 054, 3134195, "*****@*****.**");

                be.Users.Add(owner);
                be.Users.Add(admin);
                be.Businesses.Add(b);
                be.Coupons.Add(cop);
                be.SaveChanges();

                oc              = new OrderedCoupon();
                oc.SerialNum    = 4;
                oc.Status       = StatusType.NotUsed;
                oc.PurchaseDate = "27/04/1990";
                oc.Coupon       = cop;
                oc.UseDate      = "";
                oc.Rank         = "0";
                oc.Opinion      = "";
                oc.Customer     = customer;

                be.OrderedCoupons.Add(oc);
                be.SaveChanges();


                Assert.AreEqual(be.OrderedCoupons.Find(oc.SerialNum).PurchaseDate, oc.PurchaseDate);
            }
        }
Example #2
0
        public void TestRemoveCustomerInterests()
        {
            using (basicEntities be = new basicEntities())
            {
                customer = TestCustomer.AddCustomer("Customer123", "adam", "admin123123", 054, 3134195, "*****@*****.**");

                be.Users.Add(customer);

                be.SaveChanges();

                ci = new CustomerIntrests();

                ci.InterestID       = InterestType.Dancing;
                ci.CustomerUserName = customer.UserName;

                be.CustomerIntrests.Add(ci);
                be.SaveChanges();



                CustomerIntrests c = be.CustomerIntrests.Find(ci.CustomerUserName, ci.InterestID);

                if (c != null)
                {
                    be.CustomerIntrests.Remove(c);
                    be.Users.Remove(be.Users.Find(customer.UserName));
                    be.SaveChanges();
                }
            }
        }
Example #3
0
        public void TestRemoveRecommendation()
        {
            using (basicEntities be = new basicEntities())
            {
                customer = TestCustomer.AddCustomer("Customer123", "adam", "admin123123", 054, 3134195, "*****@*****.**");

                rec             = new Recommendation();
                rec.Description = "blabla";
                rec.Id          = 4;
                rec.Link        = "www.google.com";
                rec.Source      = SourceType.GooglePlus;

                rec.Customer = customer;
                be.Users.Add(customer);
                be.Recommendations.Add(rec);
                be.SaveChanges();


                be.Recommendations.Remove(rec);
                be.Users.Remove(be.Users.Find(customer.UserName));
                be.SaveChanges();

                Assert.IsNull(be.Recommendations.Find(rec.Id));
            }
        }
Example #4
0
        public static void DeleteAllustomers()
        {
            using (basicEntities be = new basicEntities())
            {
                var query = from b in be.Users
                            select b;

                foreach (Coupon.User item in query)
                {
                    if (item is Coupon.Customer)
                    {
                        TestCustomer.RemoveCustomer(item.UserName);
                    }
                }
            }
        }
Example #5
0
        public void TestAddCustomerFriend()
        {
            TestCustomer tc = new TestCustomer();

            using (basicEntities be = new basicEntities())
            {
                Customer c1 = TestCustomer.AddCustomer("Customer123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
                Customer c2 = TestCustomer.AddCustomer("Customerfriend", "adam", "admin123123", 054, 3134195, "*****@*****.**");
                c1.Customers1.Add(c2);
                be.Users.Add(c1);
                be.SaveChanges();
                Assert.IsTrue(((Customer)be.Users.Find(c1.UserName)).Customers1.Contains(c2));
                TestCustomer.RemoveCustomer("Customer123");
                TestCustomer.RemoveCustomer("Customerfriend");
            }
        }
Example #6
0
        public void TestAddCustomerInterests()
        {
            using (basicEntities be = new basicEntities())
            {
                customer = TestCustomer.AddCustomer("Customer123", "adam", "admin123123", 054, 3134195, "*****@*****.**");

                be.Users.Add(customer);

                be.SaveChanges();

                ci = new CustomerIntrests();

                ci.InterestID       = InterestType.Dancing;
                ci.CustomerUserName = customer.UserName;

                be.CustomerIntrests.Add(ci);
                be.SaveChanges();


                Assert.AreEqual(be.CustomerIntrests.Find(ci.CustomerUserName, ci.InterestID).CustomerUserName, ci.CustomerUserName);
            }
        }