public void FilterDeletedRecordsTest() { // To ensure validity of this test we need to delete orphaned records from other tests ClearDeletedTestRecords(); IEnhancedVideoDbRepository _enhancedRepo = new EnhancedVideoDbRepository( new VideoDbRepository(VideoDbContextFactory.Create(connectionString), new Microsoft.Extensions.Caching.Memory.MemoryCache( new Microsoft.Extensions.Caching.Memory.MemoryCacheOptions())), EnhancedVideoDbContextFactory.Create(connectionString), _options); var video = new DatabaseModel.videodb_videodata(); video.title = "TestVideoDeleted"; video.plot = "TestPlot"; video.owner_id = _options.DeletedOwnerId; IVideoDbRepository _videoDbRepository = new VideoDbRepository(VideoDbContextFactory.Create(connectionString)); var id = _videoDbRepository.InsertOrUpdateVideo(video); _options.FilterDeletedRecords = false; var actual = _enhancedRepo.GetMovieByTitle("TestVideoDeleted"); Assert.True(actual.Count() == 1, "Assert 1"); _options.FilterDeletedRecords = true; actual = _enhancedRepo.GetMovieByTitle("TestVideoDeleted"); Assert.True(actual.Count() == 0, "Assert 2"); _videoDbRepository.DeleteVideo(id); }
public void DeletedOwnerTests() { // To ensure validity of this test we need to delete orphaned records from other tests ClearDeletedTestRecords(); IEnhancedVideoDbRepository _enhancedRepo = new EnhancedVideoDbRepository( new VideoDbRepository(VideoDbContextFactory.Create(connectionString), new Microsoft.Extensions.Caching.Memory.MemoryCache( new Microsoft.Extensions.Caching.Memory.MemoryCacheOptions())), EnhancedVideoDbContextFactory.Create(connectionString), _options); var video = new DatabaseModel.videodb_videodata(); video.title = "TestVideoDeleted"; video.plot = "TestPlot"; video.owner_id = _options.DeletedOwnerId; IVideoDbRepository _videoDbRepository = new VideoDbRepository(VideoDbContextFactory.Create(connectionString)); var id = _videoDbRepository.InsertOrUpdateVideo(video); var actual = _enhancedRepo.GetMovieByTitle("TestVideoDeleted"); Assert.True(actual.Count() == 0, $"Assert 1: {actual.Count()}"); var deleted = _enhancedRepo.GetVideoData(id); Assert.Equal("Video has been marked as deleted (no owner).", deleted.Owner); Assert.Equal(_options.DeletedOwnerId, deleted.OwnerId); _videoDbRepository.DeleteVideo(id); }
public void GetVideoDbMovieData() { IEnhancedVideoDbRepository _videoDbRepostiory = new EnhancedVideoDbRepository( new VideoDbRepository(VideoDbContextFactory.Create(connectionString), new Microsoft.Extensions.Caching.Memory.MemoryCache( new Microsoft.Extensions.Caching.Memory.MemoryCacheOptions())), EnhancedVideoDbContextFactory.Create(connectionString), _options); var actual = _videoDbRepostiory.GetVideoData(1249); Assert.Equal(1249, actual.Id); Assert.Equal("Der Zoowärter", actual.Title); Assert.True(string.IsNullOrWhiteSpace(actual.DigitalVideoFilePath)); Assert.Equal("R08F3D02", actual.DiskId); Assert.Equal("./coverpics/1249.jpg", actual.ImgUrl); Assert.Equal("101", actual.Length); Assert.NotNull(actual.Plot); Assert.Equal("5.79", actual.Rating); Assert.True(string.IsNullOrWhiteSpace(actual.SubTitle)); Assert.Equal("Daniel", actual.Owner); Assert.Equal(3, actual.OwnerId); Assert.Equal(4, actual.Genres.Count()); Assert.Collection(actual.Genres, a => { Assert.Equal("Comedy", a); }, a => { Assert.Equal("Documentary", a); }, a => { Assert.Equal("Family", a); }, a => { Assert.Equal("Romance", a); } ); Assert.Equal("Blu-ray", actual.MediaType); Assert.Equal(16, actual.MediaTypeId); }
public void GetVideoDataWithUnvailableId() { IVideoDbRepository _videoDbRepostiory = new VideoDbRepository(VideoDbContextFactory.Create(connectionString)); var video = _videoDbRepostiory.GetVideoDataById(82); Assert.Null(video); }
public void DynamicWhereClauseTest() { var _videoDbRepository = new VideoDbRepository(VideoDbContextFactory.Create(connectionString)); var result = _videoDbRepository.GetVideoDataDynamic("id=500").FirstOrDefault(); Assert.Equal("In 80 Tagen um die Welt", result.title); }
public void GetVideoDataByTitleTest() { IVideoDbRepository _videoDbRepostiory = new VideoDbRepository(VideoDbContextFactory.Create(connectionString)); // call search with small letters "batman" var actual = _videoDbRepostiory.GetVideoDataByTitle("batman"); Assert.True(actual.Where(v => v.title.Contains("Batman")).Count() > 0); }
public void UserVideosOverRepositoryTest() { IVideoDbRepository _videoDbRepostiory = new VideoDbRepository( VideoDbContextFactory.Create(connectionString), new Microsoft.Extensions.Caching.Memory.MemoryCache( new Microsoft.Extensions.Caching.Memory.MemoryCacheOptions())); var videos = _videoDbRepostiory.GetVideoDataForUser(3); Assert.True(videos.Count() > 0); }
/// <summary> /// This method clears records with title "TestVideoDeleted" which maybe orphaned records from /// former tests. /// </summary> private void ClearDeletedTestRecords() { IVideoDbRepository _videoDbRepository = new VideoDbRepository(VideoDbContextFactory.Create(connectionString)); var orphanedRecords = _videoDbRepository.GetVideoDataByTitle("TestVideoDeleted").ToList(); foreach (var record in orphanedRecords) { _videoDbRepository.DeleteVideo(record.id); } }
public void GetVideoDataOverRepositoryTest() { IVideoDbRepository _videoDbRepostiory = new VideoDbRepository(VideoDbContextFactory.Create(connectionString)); var videos = _videoDbRepostiory.GetVideoDataById(52); Assert.True(videos.id == 52, "Wrong id."); Assert.Equal("Entführer & Gentlemen", videos.title); Assert.True(videos.VideoGenres.Count() == 1); Assert.Equal("Comedy", videos.VideoGenres.FirstOrDefault().Genre.name); Assert.Equal(2, videos.owner_id); }
public void CharSetTest() { var id = 2472; var expectedMovie = "Kirschblüten und rote Bohnen"; using (var context = VideoDbContextFactory.Create(connectionString)) { var result = context.VideoData.Where(v => v.id == id); var actual = result.FirstOrDefault().title; Assert.Equal(expectedMovie, actual); } }
public void InsertOrUpdateVideoDataTest() { var video = new videodb_videodata(); video.title = "TestVideo"; // plot was cut after 256 items, see https://github.com/viper3400/VideoDb/issues/1 var plotBuilder = new StringBuilder(); plotBuilder.Append("Lorem ipsum dolor sit amet, causae honestatis his eu. Justo quaeque gubergren at per, probo brute nihil vis no."); plotBuilder.Append("His id salutandi consectetuer. In qualisque incorrupte vis, iudico aliquip mei et, ei adolescens voluptaria duo. "); plotBuilder.Append("Atqui populo singulis cum at. In causae labores vivendo sea. In brute oporteat appellantur sed."); plotBuilder.Append("Cu odio error laboramus his, percipit iracundia argumentum eam te, ea tamquam utroque constituto mei. "); plotBuilder.Append("Odio albucius elaboraret ei est. Iudico possim nam ne, cu iusto efficiantur vix. "); plotBuilder.Append("Te eum simul albucius conclusionemque, et cum nulla eruditi intellegam. Impetus singulis no mel."); plotBuilder.Append("Usu quidam accumsan concludaturque an, pri dico inimicus."); video.plot = plotBuilder.ToString();; video.owner_id = 3; IVideoDbRepository _videoDbRepository = new VideoDbRepository(VideoDbContextFactory.Create(connectionString)); var id = _videoDbRepository.InsertOrUpdateVideo(video); Assert.True(id != 0); var actual = _videoDbRepository.GetVideoDataById(id); Assert.Equal("TestVideo", actual.title); Assert.Equal(plotBuilder.ToString(), actual.plot); Assert.Equal(3, actual.owner_id); video.title = "TestVideo (Updated)"; var updatedId = _videoDbRepository.InsertOrUpdateVideo(video); Assert.Equal(id, updatedId); Assert.Equal("TestVideo (Updated)", actual.title); Assert.Equal(plotBuilder.ToString(), actual.plot); Assert.Equal(3, actual.owner_id); var deleted = _videoDbRepository.DeleteVideo(updatedId); Assert.True(deleted); var deletedVideo = _videoDbRepository.GetVideoDataById(updatedId); Assert.Null(deletedVideo); }
public void GetAvailableUsersTest() { IVideoDbRepository _videoDbRepostiory = new VideoDbRepository( VideoDbContextFactory.Create(connectionString), new Microsoft.Extensions.Caching.Memory.MemoryCache( new Microsoft.Extensions.Caching.Memory.MemoryCacheOptions())); var users = _videoDbRepostiory.GetAvailableUsers(); Assert.True(users.Where(t => t.name == "Jan").Count() > 0); // should use cache users = _videoDbRepostiory.GetAvailableUsers(); Assert.True(users.Where(t => t.name == "Jan").Count() > 0); }
public void GetAvailableVideoGenresTest() { IVideoDbRepository _videoDbRepostiory = new VideoDbRepository( VideoDbContextFactory.Create(connectionString), new Microsoft.Extensions.Caching.Memory.MemoryCache( new Microsoft.Extensions.Caching.Memory.MemoryCacheOptions())); var genres = _videoDbRepostiory.GetAvailableGenres(); // search should be case insensitive Assert.True(genres.Where(g => g.name == "Adventure").Count() > 0); // should use cache genres = _videoDbRepostiory.GetAvailableGenres(); Assert.True(genres.Where(g => g.name == "Adventure").Count() > 0); }
public void GetVideoDbMovieByGenreTest() { IEnhancedVideoDbRepository _videoDbRepostiory = new EnhancedVideoDbRepository( new VideoDbRepository(VideoDbContextFactory.Create(connectionString), new Microsoft.Extensions.Caching.Memory.MemoryCache( new Microsoft.Extensions.Caching.Memory.MemoryCacheOptions())), EnhancedVideoDbContextFactory.Create(connectionString), _options); var actual = _videoDbRepostiory.GetMoviesByGenre(new List <string> { "Sci-Fi", "Action" }); Assert.Equal(124, actual.Count()); }
public void AccessibiltiyOfTables() { using (var context = VideoDbContextFactory.Create(connectionString)) { var result = context.Actors.ToList(); context.Cache.ToList(); context.Config.ToList(); context.Genre.ToList(); context.Genres.ToList(); context.Lent.ToList(); context.MediaTypes.ToList(); context.Permissions.ToList(); context.UserConfig.ToList(); var users = context.Users.ToList(); context.UserSeen.ToList(); var videoData = context.VideoData.ToList(); Assert.True(videoData.FirstOrDefault().VideoOwner.id > 0); Assert.True(users.Where(u => u.id == 3).FirstOrDefault().UserVideos.Count() > 0); } }