Beispiel #1
0
        public void CreateActorShouldCreateActor()
        {
            DbContextOptions <UltimateMoviesDbContext> options = new DbContextOptionsBuilder <UltimateMoviesDbContext>()
                                                                 .UseInMemoryDatabase(databaseName: "Actors_CreateActor_Database")
                                                                 .Options;
            UltimateMoviesDbContext db = new UltimateMoviesDbContext(options);

            IActorsService actorsService = new ActorsService(db);

            actorsService.CreateActor("Test Actor");
            actorsService.CreateActor("Test Actor 2");
            actorsService.CreateActor("Test Actor 3");

            int actorsCount = db.Actors.ToList().Count();

            Assert.Equal(3, actorsCount);
        }
Beispiel #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);
        }