Exemple #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);
            }
        }
        public void TestAddCouponInterests()
        {
            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);

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


                ci = new CouponInterests();

                ci.CouponId   = cop.Id;
                ci.InterestID = InterestType.Dancing;


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


                Assert.AreEqual(be.CouponInterests.Find(ci.InterestID, ci.CouponId).CouponId, ci.CouponId);
            }
        }
Exemple #3
0
 public void Cleanup()
 {
     using (basicEntities be = new basicEntities())
     {
         if (be.Businesses.Find(Businessid) != null)
         {
             be.Businesses.Remove(be.Businesses.Find(Businessid));
             be.SaveChanges();
             TestOwner.RemoveOwner(owners);
             TestAdmin.RemoveAdmin(admins);
         }
     }
 }
Exemple #4
0
 public string TestBusinessAdd()
 {
     admins = TestAdmin.TestAdminAdd();
     owners = TestOwner.TestOwnerAdd();
     using (basicEntities be = new basicEntities())
     {
         Owner    owner = (Owner)be.Users.Find(owners);
         Admin    admin = (Admin)be.Users.Find(admins);
         Business b     = AddBusinesses("123", admin, owner, "beer-Sheva", "bla", Category.CarsAccessories);
         be.Businesses.Add(b);
         be.SaveChanges();
         return(b.BusinessID);
     }
 }
Exemple #5
0
        public static void RemoveBusinesses(string BusinessID)
        {
            using (basicEntities be = new basicEntities())
            {
                Business BusinessesToRemove = be.Businesses.Find(BusinessID);
                string   owner = BusinessesToRemove.Admin.UserName;
                string   admin = BusinessesToRemove.Owner.UserName;
                be.Businesses.Remove(BusinessesToRemove);

                be.SaveChanges();
                TestOwner.RemoveOwner(owner);
                TestAdmin.RemoveAdmin(admin);
                be.SaveChanges();
            }
        }
        public static void DeleteAllOwners()
        {
            using (basicEntities be = new basicEntities())
            {
                var query = from b in be.Users
                            select b;

                foreach (Coupon.User item in query)
                {
                    if (item is Coupon.Owner)
                    {
                        TestOwner.RemoveOwner(item.UserName);
                    }
                }
            }
        }