Exemplo n.º 1
0
        public Playlist AddPlaylist(string title, int UserId)
        {
            var playlist = new Playlist()
            {
                Title  = title,
                UserId = UserId
            };

            context.Playlists.Add(playlist);
            context.SaveChanges();
            return(playlist);
        }
Exemplo n.º 2
0
        public Watchlist AddMovie(string title, int playListId, string posterPath)
        {
            var watchlist = new Watchlist()
            {
                MovieTitle = title,
                PlaylistId = playListId,
                PosterPath = posterPath
            };

            context.Watchlists.Add(watchlist);
            context.SaveChanges();
            return(watchlist);
        }
Exemplo n.º 3
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();
            }
        }
Exemplo n.º 4
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();
            }
        }
Exemplo n.º 5
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();
            }
        }
Exemplo n.º 6
0
 public User AddUser(User user)
 {
     context.Users.Add(user);
     context.SaveChanges();
     return(user);
 }