Ejemplo n.º 1
0
        public async Task AddNewActor_NewActor_AddAndSaveChanges()
        {
            //Arrange
            var actor = new ActorBuilder().WithId(1).Build();

            var dbSet   = GenerateEnumerableDbSetMock(new List <Actor>().AsQueryable());
            var context = GenerateEnumerableContextMock(dbSet);
            var service = new ActorsService(context.Object);

            //Act
            await service.AddNewActor(actor);

            //Assert
            dbSet.Verify(x => x.Add(It.IsAny <Actor>()), Times.Once);
            context.Verify(x => x.SaveChangesAsync(default(CancellationToken)), Times.Once);
        }