public async Task DeletionShouldPropagateOperationStatusFromDeletionInDB(bool successful)
        {
            var character = Mock.Of <Character>(c => c.Id == 1);

            var characterRepository = Mock.Of <CharactersRepository>(cr => cr.Delete(character) == Task.FromResult(successful));

            var characterEditor = new CharacterEditor(Mock.Of <MakeMagicApiClient>(), characterRepository);
            var result          = await characterEditor.Delete(character);

            Assert.NotEqual(successful, result.Error);
        }
Пример #2
0
        public async Task <IActionResult> Delete(int id)
        {
            var characterFromDb = await _characterRepository.Get(id);

            if (characterFromDb is null)
            {
                return(NotFound());
            }
            var characterDeletionResult = await _characterEditor.Delete(characterFromDb);

            return(HandleResponseDefault(characterDeletionResult, () => NoContent()));
        }