public async Task GetImagesTest() { var ImagesResult = await ImagesController.GetImages(); var Images = ImagesResult.Value as List <ImageDTO>; Assert.IsNotNull(Images); foreach (var Image in Images) { int i = Images.IndexOf(Image); Assert.AreEqual(Image.ImageId, DbContent[i].ImageId); Assert.AreEqual(Image.ByteImage, Convert.ToBase64String(DbContent[i].ByteImage)); } }
public async Task TestGetImages_GetValidId_ReturnImagesSuccessfully() { // Arrange int filmId = 1; imageService.Setup(i => i.GetImagesByFilmIdAsync(filmId)).ReturnsAsync(imagesList); ImagesController controller = new ImagesController(imageService.Object, mapper); // Act var result = await controller.GetImages(filmId); // Assert var okResult = result.Result as OkObjectResult; Assert.NotNull(okResult); var images = okResult.Value as IEnumerable <ImageViewModel>; Assert.NotNull(images); Assert.Equal(imagesList.Count, images.Count()); Assert.Equal("https://image1", images.FirstOrDefault().Url); imageService.Verify(i => i.GetImagesByFilmIdAsync(filmId), Times.Once); }