示例#1
0
        public void CanDeleteAd_AdExistsAndNotDeleted_ReturnTrue()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository      repo           = new Repository(sessionFactory);
            AdRepository    adRepo         = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email    = "*****@*****.**",
                    Password = "******"
                };
                repo.Save <User>(u);

                City c = new City
                {
                    Label        = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label        = "Informatique",
                    LabelUrlPart = "Informatique",
                    Type         = AdTypeEnum.Ad
                };

                Ad a = new Ad
                {
                    Title        = "video game",
                    Body         = "the best!!",
                    CreatedBy    = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category     = cat,
                    IsDeleted    = false
                };
                c.AddAd(a);
                cat.AddAd(a);
                repo.Save <Province>(p1);
                repo.Save <City>(c);
                repo.Save <Category>(cat);
                long id = repo.Save <Ad, long>(a);

                repo.Flush();

                #endregion

                Assert.IsTrue(adRepo.CanDeleteAd(id));
            }
        }
示例#2
0
        public void CanDeleteAd_AdDoesNotExists_ReturnFalse()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            AdRepository    adRepo         = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                Assert.IsFalse(adRepo.CanDeleteAd(56));
            }
        }
示例#3
0
        public void CanDeleteAd_AdDoesNotExists_ReturnFalse()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            AdRepository adRepo = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                Assert.IsFalse(adRepo.CanDeleteAd(56));
            }
        }
示例#4
0
        public void CanDeleteAd_AdExistsAndNotDeleted_ReturnTrue()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            AdRepository adRepo = new AdRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "*****@*****.**",
                    Password = "******"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Informatique",
                    LabelUrlPart = "Informatique",
                    Type = AdTypeEnum.Ad
                };

                Ad a = new Ad
                {
                    Title = "video game",
                    Body = "the best!!",
                    CreatedBy = u,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    IsDeleted = false
                };
                c.AddAd(a);
                cat.AddAd(a);
                repo.Save<Province>(p1);
                repo.Save<City>(c);
                repo.Save<Category>(cat);
                long id = repo.Save<Ad, long>(a);

                repo.Flush();

                #endregion

                Assert.IsTrue(adRepo.CanDeleteAd(id));
            }
        }