示例#1
0
        public async void AddsScreening()
        {
            var context = InMemoryDbContextFactory.GetDbContext();

            context.Movies.Add(new Movie {
                MovieId = 1
            });
            context.ScreeningRooms.Add(new ScreeningRoom {
                ScreeningRoomId = 1
            });
            await context.SaveChangesAsync();

            var controller = new ScreeningController(context);

            var time = DateTime.Now;

            var Screening = new Screening {
                DateTime = time, ScreeningRoomId = 1, MovieId = 1
            };

            var response = await controller.AddScreening(Screening);

            Assert.IsType <OkObjectResult>(response.Result);
            var okRes = (OkObjectResult)response.Result;

            Assert.Equal(time, ((Screening)okRes.Value).DateTime);
        }
示例#2
0
        public void InstantiatesController()
        {
            var context    = InMemoryDbContextFactory.GetDbContext();
            var controller = new ScreeningController(context);

            Assert.NotNull(controller);
        }
        private static Context CreateDbContextMock()
        {
            var entries = new List <ImageEntry>
            {
                new ImageEntry(null, 1)
            }.AsQueryable();

            var context = InMemoryDbContextFactory.GetDbContext();

            context.Entries.AddRange(entries);
            context.SaveChanges();
            return(context);
        }
示例#4
0
        public void GetsScreeningRooms()
        {
            var context = InMemoryDbContextFactory.GetDbContext();

            context.ScreeningRooms.AddRange(new ScreeningRoom(), new ScreeningRoom());
            context.SaveChanges();
            var controller = new ScreeningRoomsController(context);

            var response = controller.GetScreeningRooms();

            Assert.IsType <OkObjectResult>(response.Result);
            var okRes = (OkObjectResult)response.Result;

            Assert.Equal(2, ((List <ScreeningRoom>)okRes.Value).Count);
        }
示例#5
0
        public void GetsMovies()
        {
            var context = InMemoryDbContextFactory.GetDbContext();

            context.Movies.AddRange(new Movie(), new Movie());
            context.SaveChanges();
            var controller = new MovieController(context);

            var response = controller.GetMovies();

            Assert.IsType <OkObjectResult>(response.Result);
            var okRes = (OkObjectResult)response.Result;

            Assert.Equal(2, ((List <Movie>)okRes.Value).Count);
        }
示例#6
0
        public void GetsScreenings()
        {
            var context = InMemoryDbContextFactory.GetDbContext();

            context.Screenings.AddRange(new Screening {
                ScreeningId = 1
            }, new Screening {
                ScreeningId = 2
            });
            context.SaveChanges();
            var controller = new ScreeningController(context);

            var response = controller.GetScreenings();

            Assert.IsType <OkObjectResult>(response.Result);
        }
示例#7
0
        public async void AddsScreeningRoom()
        {
            var context    = InMemoryDbContextFactory.GetDbContext();
            var controller = new ScreeningRoomsController(context);

            var ScreeningRoom = new ScreeningRoom {
                Name = "room1"
            };

            var response = await controller.AddScreeningRoom(ScreeningRoom);

            Assert.IsType <OkObjectResult>(response.Result);
            var okRes = (OkObjectResult)response.Result;

            Assert.Equal("room1", ((ScreeningRoom)okRes.Value).Name);
        }
示例#8
0
        public async void AddsMovie()
        {
            var context    = InMemoryDbContextFactory.GetDbContext();
            var controller = new MovieController(context);

            var movie = new Movie {
                Title = "Testing Movie1"
            };

            var response = await controller.AddMovie(movie);

            Assert.IsType <OkObjectResult>(response.Result);
            var okRes = (OkObjectResult)response.Result;

            Assert.Equal("Testing Movie1", ((Movie)okRes.Value).Title);
        }
示例#9
0
        public async void DeletesScreening()
        {
            var context = InMemoryDbContextFactory.GetDbContext();

            context.Add(new Screening {
                ScreeningId = 1
            });
            await context.SaveChangesAsync();

            var controller = new ScreeningController(context);

            var response = await controller.DeleteScreening(1);

            Assert.IsType <OkObjectResult>(response.Result);
            var okRes = (OkObjectResult)response.Result;

            Assert.Equal(1, ((Screening)okRes.Value).ScreeningId);
        }
示例#10
0
        public async void DeletesScreeningRoom()
        {
            var context = InMemoryDbContextFactory.GetDbContext();

            context.Add(new ScreeningRoom {
                ScreeningRoomId = 1, Name = "room1"
            });
            await context.SaveChangesAsync();

            var controller = new ScreeningRoomsController(context);

            var response = await controller.DeleteScreeningRoom(1);

            Assert.IsType <OkObjectResult>(response.Result);
            var okRes = (OkObjectResult)response.Result;

            Assert.Equal("room1", ((ScreeningRoom)okRes.Value).Name);
        }
示例#11
0
        public async void DeletesMovie()
        {
            var context = InMemoryDbContextFactory.GetDbContext();

            context.Add(new Movie {
                MovieId = 1, Title = "Testing Movie1"
            });
            await context.SaveChangesAsync();

            var controller = new MovieController(context);

            var response = await controller.DeleteMovie(1);

            Assert.IsType <OkObjectResult>(response.Result);
            var okRes = (OkObjectResult)response.Result;

            Assert.Equal("Testing Movie1", ((Movie)okRes.Value).Title);
        }