Пример #1
0
        public async Task GetAllActors_ActorCountIs3_ListWith3Actors()
        {
            //Arrange
            var data = new List <Actor>()
            {
                new ActorBuilder().Build(),
                new ActorBuilder().Build(),
                new ActorBuilder().Build(),
            }.AsQueryable();
            var dbSet   = GenerateEnumerableDbSetMock(data);
            var context = GenerateEnumerableContextMock(dbSet);
            var service = new ActorsService(context.Object);

            //Act
            var resultList = await service.GetAllActors();

            //Assert
            Assert.Equal(3, resultList.Count);
        }
Пример #2
0
        public void GetAllActorsShouldReturnAllActors()
        {
            DbContextOptions <UltimateMoviesDbContext> options = new DbContextOptionsBuilder <UltimateMoviesDbContext>()
                                                                 .UseInMemoryDatabase(databaseName: "Actors_GetAllActors_Database")
                                                                 .Options;
            UltimateMoviesDbContext db = new UltimateMoviesDbContext(options);

            IActorsService actorsService = new ActorsService(db);

            actorsService.CreateActor("Name 1");
            actorsService.CreateActor("Name 2");
            actorsService.CreateActor("Name 3");
            actorsService.CreateActor("Name 4");

            List <Actor> actors = actorsService.GetAllActors().ToList();

            int actorsCount = actors.Count();

            Assert.Equal(4, actorsCount);
        }