public async Task GetEmbededLinkWorkFine() { var videoList = new List <Video>(); var videoRepo = new Mock <IDeletableEntityRepository <Video> >(); videoRepo.Setup(x => x.All()).Returns(videoList.AsQueryable()); videoRepo.Setup(x => x.AddAsync(It.IsAny <Video>())) .Callback((Video r) => videoList.Add(r)); var videoService = new VideosService(videoRepo.Object); await videoService.CreateAsync(test.Title, test.Description, test.VideoUrl, test.Category); await videoService.CreateAsync(test2.Title, test2.Description, test2.VideoUrl, test2.Category); var embededLink = videoService.GetEmbededVideoLink(test.VideoUrl); var embededLink2 = videoService.GetEmbededVideoLink(test2.VideoUrl); Assert.Equal("w2ze3Z6BAmg", embededLink); Assert.Equal("03ILbXdE8b4", embededLink2); }