示例#1
0
        public void TestRemoveVisit()
        {
            using (basicEntities be = new basicEntities())
            {
                visit      = new Visit();
                visit.Id   = 1;
                visit.Date = "01/01/2004";
                Location l = new Location();
                l.Longitude    = 34.791462;
                l.Latitude     = 31.252973;
                visit.Location = l;
                ((Customer)customer).Visits.Add(visit);
                be.Users.Add(customer);
                be.Visits.Add(visit);

                be.SaveChanges();


                be.Visits.Remove(be.Visits.Find(visit.Id));
                be.Users.Remove(be.Users.Find("customer"));
                be.Locations.Remove(be.Locations.Find(l.Id));
                be.SaveChanges();


                Assert.IsNull(be.Visits.Find(visit.Id));
            }
        }
示例#2
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));
            }
        }
示例#3
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();
                }
            }
        }
示例#4
0
        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);
            }
        }
示例#5
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);
            }
        }
示例#6
0
 public void TestAddCoupon()
 {
     coupon = TestCouponAdd();
     using (basicEntities be = new basicEntities())
     {
         Assert.AreEqual(be.Coupons.Find(coupon).Id, coupon);
     }
 }
示例#7
0
 public void TestAddBusiness()
 {
     using (basicEntities be = new basicEntities())
     {
         Businessid = TestBusinessAdd();
         Assert.AreEqual(be.Businesses.Find(Businessid).BusinessID, Businessid);
     }
 }
示例#8
0
 public bool IsEmailExist(string email)
 {
     using (basicEntities db = new basicEntities())
     {
         var v = db.tblUsers.Where(a => a.Email == email).FirstOrDefault();
         return(v != null);
     }
 }
示例#9
0
 public void TestRemoveBusiness()
 {
     Businessid = TestBusinessAdd();
     using (basicEntities be = new basicEntities())
     {
         RemoveBusinesses(Businessid);
         Assert.AreEqual(be.Businesses.Find(Businessid), null);
     }
 }
示例#10
0
 public void TestRemoveCoupon()
 {
     coupon = TestCouponAdd();
     using (basicEntities be = new basicEntities())
     {
         RemoveCoupon(coupon);
         Assert.AreEqual(be.Coupons.Find(coupon), null);
     }
 }
示例#11
0
 public void TestAddAdmin()
 {
     using (basicEntities be = new basicEntities())
     {
         string username = TestAdminAdd();
         Assert.AreEqual(be.Users.Find(username).UserName, username);
         RemoveAdmin(username);
     }
 }
示例#12
0
 public void TestAddCustomer()
 {
     using (basicEntities be = new basicEntities())
     {
         string username = TestCustomerAdd();
         Assert.AreEqual(be.Users.Find(username).UserName, username);
         RemoveCustomer(username);
     }
 }
示例#13
0
 public static void RemoveUser(string user)
 {
     using (basicEntities be = new basicEntities())
     {
         User userToRemove = be.Users.Find(user);
         be.Users.Remove(userToRemove);
         be.SaveChanges();
     }
 }
示例#14
0
 public static string TestOwnerAdd()
 {
     using (basicEntities be = new basicEntities())
     {
         Owner o = AddOwner("owner123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
         be.Users.Add(o);
         be.SaveChanges();
         return(o.UserName);
     }
 }
示例#15
0
        public void TestRemoveCustomer()
        {
            string username = TestCustomerAdd();

            using (basicEntities be = new basicEntities())
            {
                RemoveCustomer(username);
                Assert.AreEqual(be.Users.Find(username), null);
            }
        }
示例#16
0
        public static void RemoveAdmin(string admin)
        {
            using (basicEntities be = new basicEntities())
            {
                User AdminToRemove = be.Users.Find(admin);

                be.Users.Remove(AdminToRemove);
                be.SaveChanges();
            }
        }
示例#17
0
 public static string TestUserAdd()
 {
     using (basicEntities be = new basicEntities())
     {
         User u = AddUser("User123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
         be.Users.Add(u);
         be.SaveChanges();
         return(u.UserName);
     }
 }
示例#18
0
        public static string TestAdminAdd()
        {
            using (basicEntities be = new basicEntities())
            {
                Admin A = AddAdmin("Admin123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
                be.Users.Add(A);
                be.SaveChanges();

                return(A.UserName);
            }
        }
示例#19
0
 public void Cleanup()
 {
     using (basicEntities be = new basicEntities())
     {
         if (be.Locations.Find(loc.Id) != null)
         {
             be.Locations.Remove(be.Locations.Find(loc.Id));
             be.SaveChanges();
         }
     }
 }
示例#20
0
        public string TestCustomerAdd()
        {
            using (basicEntities be = new basicEntities())
            {
                Customer c = AddCustomer("Customer123", "adam", "admin123123", 054, 3134195, "*****@*****.**");
                be.Users.Add(c);
                be.SaveChanges();

                return(c.UserName);
            }
        }
示例#21
0
 public static void RemoveCoupon(int CouponID)
 {
     using (basicEntities be = new basicEntities())
     {
         Coupon.Coupon CouponToRemove = be.Coupons.Find(CouponID);
         string        Businessid     = CouponToRemove.Business.BusinessID;
         be.Coupons.Remove(CouponToRemove);
         be.SaveChanges();
         TestBusiness.RemoveBusinesses(Businessid);
         be.SaveChanges();
     }
 }
示例#22
0
        public void TestUpdateBusiness()
        {
            using (basicEntities be = new basicEntities())
            {
                Businessid = TestBusinessAdd();

                be.Businesses.Find(Businessid).Address = "tel ron";
                be.SaveChanges();

                Assert.AreEqual(be.Businesses.Find(Businessid).Address, "tel ron");
            }
        }
示例#23
0
 public void Cleanup()
 {
     using (basicEntities be = new basicEntities())
     {
         if (be.Coupons.Find(coupon) != null)
         {
             be.Coupons.Remove(be.Coupons.Find(coupon));
             be.SaveChanges();
             TestBusiness.RemoveBusinesses(Businessid);
             be.SaveChanges();
         }
     }
 }
示例#24
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);
         }
     }
 }
示例#25
0
        public void TestUpdateUser()
        {
            using (basicEntities be = new basicEntities())
            {
                string username = TestUserAdd();

                be.Users.Find(username).Name = "sos";
                be.SaveChanges();

                Assert.AreEqual(be.Users.Find(username).Name, "sos");
                RemoveUser(username);
            }
        }
示例#26
0
        public static void DeleteAllUser()
        {
            using (basicEntities be = new basicEntities())
            {
                var query = from b in be.Users
                            select b;

                foreach (Coupon.User item in query)
                {
                    TestUser.RemoveUser(item.UserName);
                }
            }
        }
示例#27
0
        public static void DeleteAllBusiness()
        {
            using (basicEntities be = new basicEntities())
            {
                var query = from b in be.Businesses
                            select b;

                foreach (Coupon.Business item in query)
                {
                    TestBusiness.RemoveBusinesses(item.BusinessID);
                }
            }
        }
示例#28
0
 public void Cleanup()
 {
     using (basicEntities be = new basicEntities())
     {
         if (be.Visits.Find(visit.Id) != null)
         {
             be.Visits.Remove(be.Visits.Find(visit.Id));
             be.Users.Remove(be.Users.Find("customer"));
             be.Locations.Remove(be.Locations.Find(l.Id));
             be.SaveChanges();
         }
     }
 }
示例#29
0
        public static void DeleteAllCoupons()
        {
            using (basicEntities be = new basicEntities())
            {
                var query = from b in be.Coupons
                            select b;

                foreach (Coupon.Coupon item in query)
                {
                    TestCoupon.RemoveCoupon(item.Id);
                }
            }
        }
示例#30
0
        public int TestCouponAdd()
        {
            TestBusiness bn = new TestBusiness();

            Businessid = bn.TestBusinessAdd();
            using (basicEntities be = new basicEntities())
            {
                Business      b   = be.Businesses.Find(Businessid);
                Coupon.Coupon cop = CreateCoupon(2, "Fly PIZZA", "100", "40", b, "10/10/2014", 8);
                be.Coupons.Add(cop);
                be.SaveChanges();
                return(cop.Id);
            }
        }