public async Task UpdateActor_WithoutActor_False() { //Arrange var actor = new ActorBuilder().WithId(1).Build(); var data = new List <Actor>() { actor }.AsQueryable(); var dbSet = GenerateEnumerableDbSetMock(data); var context = GenerateEnumerableContextMock(dbSet); //context.Setup(x => x.Actors.FindAsync(It.IsAny<int>())).ReturnsAsync(null); var service = new ActorsService(context.Object); var updatedActor = new ActorBuilder() .WithId(1) .WithFirstname("John") .WithFirstname("Smith") .Build(); //Act var result = await service.UpdateActor(updatedActor); //Assert Assert.False(result); }
public async Task UpdateActor_HasActor_SaveChanges() { //Arrange var actor = new ActorBuilder().WithId(1).Build(); var data = new List <Actor>() { actor }.AsQueryable(); var dbSet = GenerateEnumerableDbSetMock(data); var context = GenerateEnumerableContextMock(dbSet); context.Setup(x => x.Actors.FindAsync(It.IsAny <int>())).ReturnsAsync(actor); var service = new ActorsService(context.Object); var updatedActor = new ActorBuilder() .WithId(1) .WithFirstname("John") .WithFirstname("Smith") .Build(); //Act await service.UpdateActor(updatedActor); //Assert context.Verify(x => x.SaveChangesAsync(default(CancellationToken)), Times.Once); }