public async Task GetVideosByIds_Should_Throw_ArgumentNullException_If_Type_Is_Null() { VideoServiceMock mock = VideoServiceMock.Create(); List <int> ids = null; await Assert.ThrowsAsync <ArgumentNullException>(() => mock.GetVideosByIds(ids)); mock.VideoRepository.Verify(repository => repository.GetVideosByIds(It.IsAny <IList <int> >()), Times.Never); }
public async Task GetVideosByIds_Should_Return_Call_IVideoRepository_GetVideosByIds() { VideoServiceMock mock = VideoServiceMock.Create(); var ids = new List <int>() { 1, 3, 5 }; mock.VideoRepository .Setup(repository => repository.GetVideosByIds(It.Is <IList <int> >(t => t.Any(i => ids.Contains(i))))) .ReturnsAsync(() => new List <Video>()); mock.VideoModelMapper.Setup(mapper => mapper.Map(It.IsAny <IEnumerable <Video> >())) .ReturnsAsync(() => new List <VideoModel>()); IEnumerable <VideoModel> videoModels = await mock.GetVideosByIds(ids); mock.VideoRepository.Verify(repository => repository.GetVideosByIds(It.IsAny <IList <int> >()), Times.Once); Assert.NotNull(videoModels); }