Example #1
0
        public void AddNull_Exception_Test()
        {
            // Arrange

            var repo = new JsonVideoRepository();

            // Act

            Assert.Throws <ArgumentNullException>(() => repo.Add(null));
        }
Example #2
0
        public void AddSameVideo_Success_Test()
        {
            // Arrange

            var repo   = new JsonVideoRepository();
            var video1 = MakeTestVideo();
            var video2 = MakeTestVideo();

            // Act

            repo.Add(video1);
            repo.Add(video2);
            var result = repo.GetAllVideos();

            // Assert

            Assert.True(result.Count == 1);
            Assert.Equal(result[0], video1);
        }
Example #3
0
        public void AddVideo_Success_Test()
        {
            // Arrange

            var repo  = new JsonVideoRepository();
            var video = MakeTestVideo();

            // Act

            repo.Add(video);
            var result = repo.GetVideo(video.VideoUrl);

            // Assert

            Assert.Equal(video, result);
        }
Example #4
0
        public void GetVideo_Null_Test()
        {
            // Arrange

            var repo  = new JsonVideoRepository();
            var video = MakeTestVideo();

            repo.Add(video);

            // Act

            var result = repo.GetVideo("unknown");

            // Assert

            Assert.Null(result);
        }
Example #5
0
        public void RemoveByUrl_Success_Test()
        {
            // Arrange

            var repo  = new JsonVideoRepository();
            var video = MakeTestVideo();

            repo.Add(video);

            // Act

            repo.Remove(video.VideoUrl);
            var result = repo.GetVideo(video.VideoUrl);

            // Assert

            Assert.Null(result);
        }
Example #6
0
        public void ClearVideos_Success_Test()
        {
            // Arrange

            var repo = new JsonVideoRepository();

            for (var i = 0; i < 10; i++)
            {
                var video = MakeTestVideo($"url_{i}");
                repo.Add(video);
            }

            // Act

            repo.Clear();
            var result = repo.GetAllVideos();

            // Assert

            Assert.True(result.Count == 0);
        }
Example #7
0
        public void GetAllVideos_Success_Test()
        {
            // Arrange

            const int count     = 10;
            var       repo      = new JsonVideoRepository();
            var       videoList = new List <Video>(10);

            for (var i = 0; i < count; i++)
            {
                var video = MakeTestVideo($"url_{i}");
                repo.Add(video);
                videoList.Add(video);
            }

            // Act

            var result = repo.GetAllVideos();

            // Assert

            Assert.True(result.Count == count);
            Assert.True(result.All(v => videoList.Contains(v)));
        }