Beispiel #1
0
        public async Task Delete_given_non_existing_character_does_not_call_SaveChangesAsync()
        {
            var character = new Character();
            var mock      = new Mock <IFuturamaContext>();

            mock.Setup(m => m.Characters.FindAsync(42)).ReturnsAsync(default(Character));

            using (var repository = new EntityFrameworkCharacterRepository(mock.Object))
            {
                await repository.DeleteAsync(42);
            }

            mock.Verify(m => m.SaveChangesAsync(default(CancellationToken)), Times.Never);
        }
Beispiel #2
0
        public async Task Delete_given_existing_character_removes_it()
        {
            var character = new Character();
            var mock      = new Mock <IFuturamaContext>();

            mock.Setup(m => m.Characters.FindAsync(42)).ReturnsAsync(character);

            using (var repository = new EntityFrameworkCharacterRepository(mock.Object))
            {
                await repository.DeleteAsync(42);
            }

            mock.Verify(m => m.Characters.Remove(character));
        }