public async Task UpdateAudioAsync_ForExistingAudio_UpdatesAsExpected() { var repo = Substitute.For <IAudioEntriesRepository>(); var sut = new AudioServiceBuilder() .WithAudioEntriesRepo(repo) .Build(); await sut.UpdateAudioAsync(new Audio(), CancellationToken.None); repo.Received().Update(Arg.Any <Audio>()); }
public void UpdateAudioAsync_FailedForNonexistentId_ThrowsNotFoundException() { var repo = Substitute.For <IAudioEntriesRepository>(); repo.When(x => x.Update(Arg.Any <Audio>())) .Do(x => throw new DbUpdateConcurrencyException("", new List <IUpdateEntry> { null })); var sut = new AudioServiceBuilder() .WithAudioEntriesRepo(repo) .Build(); Func <Task> actualAction = async() => await sut.UpdateAudioAsync(new Audio(), CancellationToken.None); actualAction.Should().Throw <KeyNotFoundException>(); }