Пример #1
0
        public void GetAll()
        {
            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new FlixContext(options))
            {
                context.Watchlists.Add(new Watchlist {
                    Id = 1, MovieTitle = "Goodfellas", PlaylistId = 1
                });
                context.Watchlists.Add(new Watchlist {
                    Id = 2, MovieTitle = "God father", PlaylistId = 1
                });
                context.SaveChanges();
            }

            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                var watchlist = new WatchlistRepository(context);
                var addMovie  = watchlist.Getall();



                Assert.AreEqual(2, addMovie.Count);

                context.Dispose();
            }
        }
Пример #2
0
        public void GetAllPlaylist()
        {
            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new FlixContext(options))
            {
                context.Playlists.Add(new Playlist {
                    Id = 1, Title = "Mafia", UserId = 1
                });
                context.Playlists.Add(new Playlist {
                    Id = 2, Title = "Comedy", UserId = 1
                });
                context.Playlists.Add(new Playlist {
                    Id = 3, Title = "Action", UserId = 1
                });
                context.Playlists.Add(new Playlist {
                    Id = 4, Title = "Action", UserId = 2
                });
                context.SaveChanges();
            }

            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                PlaylistRepository playlistRepo = new PlaylistRepository(context);
                var playlists = playlistRepo.GetAllPlaylists();

                Assert.AreEqual(4, playlists.Count);

                context.Dispose();
            }
        }
Пример #3
0
        public void GetAllUsers()
        {
            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new FlixContext(options))
            {
                context.Users.Add(new User {
                    Id = 1, UserName = "******", EmailAddress = "*****@*****.**", Password = "******", FirstName = "Glen", LastName = "dev"
                });
                context.Users.Add(new User {
                    Id = 2, UserName = "******", EmailAddress = "*****@*****.**", Password = "******", FirstName = "Dev", LastName = "dev"
                });
                context.Users.Add(new User {
                    Id = 3, UserName = "******", EmailAddress = "*****@*****.**", Password = "******", FirstName = "Last", LastName = "dev"
                });
                context.SaveChanges();
            }

            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                UserRepository userRepo = new UserRepository(context);
                var            users    = userRepo.GetAllUsers();

                Assert.AreEqual(3, users.Count);

                context.Dispose();
            }
        }
Пример #4
0
        public void DeleteUserByID()
        {
            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;

            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                UserRepository userRepo   = new UserRepository(context);
                var            users      = userRepo.DeleteUser(1);
                var            getAllUser = userRepo.GetAllUsers();

                Assert.AreEqual(3, getAllUser.Count);

                context.Dispose();
            }
        }
Пример #5
0
        public void GetMovie()
        {
            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;



            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                WatchlistRepository userRepo = new WatchlistRepository(context);
                var playlist = userRepo.GetWatchlistById(2);

                Assert.AreEqual("God father", playlist.MovieTitle);
                context.Dispose();
            }
        }
Пример #6
0
        public void DeleteByPlaylistId()
        {
            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;

            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                PlaylistRepository playlistRepo = new PlaylistRepository(context);
                var playlist       = playlistRepo.DeletePlayListById(1);
                var getAllPlaylist = playlistRepo.GetAllPlaylists();

                Assert.AreEqual(4, getAllPlaylist.Count);

                context.Dispose();
            }
        }
Пример #7
0
        public void    GetListofPlaylistbyUserId()
        {
            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;


            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                PlaylistRepository userRepo = new PlaylistRepository(context);
                var playlist = userRepo.GetAllPlaylistByUserId(1);

                Assert.AreEqual(2, playlist.Count);

                context.Dispose();
            }
        }
Пример #8
0
        public void    DeleteMovieFromPlaylist()
        {
            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;


            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                WatchlistRepository userRepo = new WatchlistRepository(context);
                var playlist = userRepo.DeleteMovieFromPlaylist(1);
                var getall   = userRepo.Getall();

                Assert.AreEqual(2, getall.Count);

                context.Dispose();
            }
        }
Пример #9
0
        public void GetUserByID()
        {
            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;



            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                UserRepository userRepo = new UserRepository(context);
                var            users    = userRepo.GetUserByID(1);

                Assert.AreEqual("Glen", users.UserName);
                Assert.AreEqual("*****@*****.**", users.EmailAddress);
                Assert.AreEqual("MGzYMsUyPHfnIfSDNsdRrQ==", users.Password);
                context.Dispose();
            }
        }
Пример #10
0
        public void AddPlaylist()
        {
            string title  = "Super Hero";
            int    userId = 2;


            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;

            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                PlaylistRepository playlist = new PlaylistRepository(context);
                var users = playlist.AddPlaylist(title, userId);

                Assert.AreEqual(title, users.Title);
                Assert.AreEqual(userId, users.UserId);

                context.Dispose();
            }
        }
Пример #11
0
        public void AddUser()
        {
            var newUser = new User()
            {
                Id = 4, UserName = "******", EmailAddress = "*****@*****.**", Password = "******", FirstName = "Glen", LastName = "dev"
            };

            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;

            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                UserRepository userRepo = new UserRepository(context);
                var            users    = userRepo.AddUser(newUser);

                Assert.AreEqual(users, newUser);

                context.Dispose();
            }
        }
Пример #12
0
        public void EditTitlePlaylist()
        {
            string titleofPlaylist = "Mafia Collection";
            int    id = 4;

            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;


            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                PlaylistRepository userRepo = new PlaylistRepository(context);
                var playlist = userRepo.EditPlayList(titleofPlaylist, id);
                var findId   = userRepo.GetPlaylistById(4);

                Assert.AreEqual(titleofPlaylist, findId.Title);

                context.Dispose();
            }
        }
Пример #13
0
        public void AddPlaylist()
        {
            string title      = "MovieName";
            int    playListId = 2;


            var options = new DbContextOptionsBuilder <FlixContext>()
                          .UseInMemoryDatabase(databaseName: "FlixUsersDatabase")
                          .Options;

            // Use a clean instance of the context to run the test
            using (var context = new FlixContext(options))
            {
                WatchlistRepository playlist = new WatchlistRepository(context);
                var users     = playlist.AddMovie(title, playListId, "hello");
                var playlist1 = playlist.Getall();

                Assert.AreEqual(3, playlist1.Count);

                context.Dispose();
            }
        }
Пример #14
0
 public UserController(IUserReposistory user, FlixContext context)
 {
     _userRepo = user;
     _context  = context;
 }
Пример #15
0
 public WatchlistRepository(FlixContext context)
 {
     this.context = context;
 }
Пример #16
0
 public UserRepository(FlixContext context)
 {
     this.context = context;
 }
Пример #17
0
 public PlaylistRepository(FlixContext context)
 {
     this.context = context;
 }