Пример #1
0
        public async void DeleteExistingCharacter()
        {
            // Given
            using (var db = new AmstramgramContext(_options, _dbLogger.Object))
            {
                var character3100 = new Character {
                    Id = 3100, Name = "Character3100"
                };
                await db.Characters.AddAsync(character3100);

                await db.SaveChangesAsync();
            }

            // When
            _characterRepository.Delete(3100);
            var saved = await _characterRepository.SaveChangesAsync();

            // Then
            Assert.True(saved);
            using (var db = new AmstramgramContext(_options, _dbLogger.Object))
            {
                var deletedCharacter = await db.Characters.FindAsync(3100);

                Assert.Null(deletedCharacter);
            }
        }
Пример #2
0
        public ActionResult Delete(Character content)
        {
            characterRepository.Delete(content);
            if (UnitOfWork.Save() != 1)
            {
                return(Content("{success:false}"));
            }

            return(Content("{success:true}"));
        }
Пример #3
0
        public void Delete_given_id_not_exists_return_false()
        {
            var mock = new Mock <IFuturamaContext>();

            mock.Setup(s => s.Characters.Find(42)).Returns(default(Character));

            var repository = new CharacterRepository(mock.Object);

            var deleted = repository.Delete(42);

            Assert.False(deleted);
        }
Пример #4
0
        private static void DeleteCharacter(CharacterRepository repo)
        {
            int id = UserIO.PromptUserForInt("Enter Id to remove");

            repo.Delete(id);
            Character deletedInfo = repo.ReadById(UserIO.PromptUserForInt("Enter Id for character"));

            if (deletedInfo == null)
            {
                Console.WriteLine("No character found");
            }
        }
        public ActionResult CharacterDelete(int characterID, string imageAddress)
        {
            string Paath = Server.MapPath("~/Images/");

            imageAddress = imageAddress.Substring(imageAddress.IndexOf("/"));
            FileInfo path = new FileInfo(Paath + imageAddress);

            path.Delete();

            CharacterRepository.Delete(characterID);
            return(RedirectToAction("CharatcterList"));
        }
Пример #6
0
        public void Delete_given_id_exists_return_true()
        {
            var entity = new Character();
            var mock   = new Mock <IFuturamaContext>();

            mock.Setup(s => s.Characters.Find(42)).Returns(entity);

            var repository = new CharacterRepository(mock.Object);

            var deleted = repository.Delete(42);

            Assert.True(deleted);
        }
Пример #7
0
        public void Delete_given_id_exists_context_SaveChanges()
        {
            var entity = new Character();
            var mock   = new Mock <IFuturamaContext>();

            mock.Setup(s => s.Characters.Find(42)).Returns(entity);

            var repository = new CharacterRepository(mock.Object);

            repository.Delete(42);

            mock.Verify(s => s.SaveChanges());
        }
        public void Delete_given_a_non_existing_character_it_returns_false()
        {
            var mock = new Mock <IFuturamaContext>();

            mock.Setup(m => m.Characters.Find(42)).Returns(default(Character));

            using (var repository = new CharacterRepository(mock.Object))
            {
                var result = repository.Delete(42);

                Assert.False(result);
            }
        }
        public void Delete_given_an_existing_character_it_returns_true()
        {
            var character = new Character();
            var mock      = new Mock <IFuturamaContext>();

            mock.Setup(m => m.Characters.Find(42)).Returns(character);
            mock.Setup(m => m.Characters.Remove(character));

            using (var repository = new CharacterRepository(mock.Object))
            {
                var result = repository.Delete(42);

                Assert.True(result);
            }
        }
Пример #10
0
        public void Delete_given_42_deletes_character_and_SaveChanges()
        {
            var character = new Character();
            var mock      = new Mock <IFuturamaContext>();

            mock.Setup(m => m.Characters.Find(42)).Returns(character);
            mock.Setup(m => m.Characters.Remove(character));

            using (var repository = new CharacterRepository(mock.Object))
            {
                repository.Delete(42);
            }

            mock.Verify(m => m.SaveChanges());
        }
Пример #11
0
 public IActionResult Delete(int id)
 {
     _characterRepository.Delete(id);
     return(NoContent());
 }
Пример #12
0
 public void Delete(Character obj, DbTransaction transaction = null)
 {
     _characterRepository.Delete(obj, transaction);
 }