public void testDelete()
        {
            // Arrange
            repo.Add(entity);
            repo.SaveChanges();
            int count = repo.All().Count();

            Guid id = repo.Get(x => x.FirstName == fn &&
                               x.LastName == ln).FirstOrDefault().Id;

            // Act
            repo.Delete(entity);
            repo.SaveChanges();
            // Assert

            Assert.IsEmpty(repo.Get(x => (x.FirstName == fn &&
                                          x.LastName == ln && x.IsDeleted == false)));

            Assert.True(repo.All().Count() == count - 1);
            Assert.True(repo.GetById(id).IsDeleted);

            this.repo.HardDelete(entity);
            this.repo.SaveChanges();

            //TODO add all remaining methods
        }
Exemple #2
0
        public void IsDeleteable()
        {
            object id = 6546;//test object to be deleted id
            HttpResponseMessage response = repository.Delete(id);
            string        jsonContents   = response.Content.ReadAsStringAsync().Result;
            Administrator deletedAdmin   = JsonConvert.DeserializeObject <Administrator>(jsonContents);

            Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.Created, "Admnistrator deletion test has failed.");
            Assert.Equals(deletedAdmin.PersonalCode, id);
        }
        public void DeleteAdministrator()
        {
            var options = new DbContextOptionsBuilder <BetterCalmContext>()
                          .UseInMemoryDatabase(databaseName: "MSP.BetterCalmDatabase").Options;
            var context = new BetterCalmContext(options);

            listAdministrators.ForEach(track => context.Add(track));
            context.SaveChanges();
            repository = new AdministratorRepository(context);
            repository.Delete(listAdministrators[0]);
            context.Database.EnsureDeleted();
            Administrator getAdmin = repository.Get(1);

            Assert.AreEqual(null, getAdmin);
        }
        public void DeleteAdministratorTest()
        {
            Administrator administrator = new Administrator()
            {
                Id       = 1,
                Email    = "*****@*****.**",
                Password = "******"
            };

            _context.Add(administrator);
            _context.SaveChanges();
            var repository = new AdministratorRepository(_context);

            repository.Delete(administrator);

            Assert.IsNull(_context.Find <Administrator>(1));
        }
Exemple #5
0
        public JsonResult DeleteAdministrator(int id)
        {
            AdministratorRepository adminRepository = new AdministratorRepository();

            if (id == AuthenticationManager.LoggedUser.Id)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            else
            {
                Administrator admin = adminRepository.GetById(id);
                if (admin != null)
                {
                    adminRepository.Delete(admin);
                }
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #6
0
 public async Task Delete(int id)
 {
     await _administratorRepository.Delete(id);
 }
 public JsonResult DeleteAdministrator(int id)
 {
     AdministratorRepository adminRepository = new AdministratorRepository();
     if (id == AuthenticationManager.LoggedUser.Id)
     {
         return Json(false, JsonRequestBehavior.AllowGet);
     }
     else
     {
         Administrator admin = adminRepository.GetById(id);
         if (admin != null)
         {
             adminRepository.Delete(admin);
         }
         return Json(true, JsonRequestBehavior.AllowGet);
     }
 }