public void AddNull_Exception_Test() { // Arrange var repo = new JsonVideoRepository(); // Act Assert.Throws <ArgumentNullException>(() => repo.Add(null)); }
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); }
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); }
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); }
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); }
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); }
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))); }