예제 #1
0
        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);
        }
예제 #2
0
        public void GetVideoDataWithUnvailableId()
        {
            IVideoDbRepository _videoDbRepostiory
                = new VideoDbRepository(VideoDbContextFactory.Create(connectionString));

            var video = _videoDbRepostiory.GetVideoDataById(82);

            Assert.Null(video);
        }
예제 #3
0
        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);
        }