Ejemplo n.º 1
0
        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>());
        }
Ejemplo n.º 2
0
        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>();
        }