示例#1
0
        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);
        }
示例#2
0
        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);
        }