public async Task Get_Images_By_Source() { using var stream = File.OpenRead("Assets/test.png"); var imageFile = new FormFile(stream, 0, stream.Length, null, Path.GetFileName(stream.Name)); var imageInfos = new List <(ResourceType sourceType, string sourceId)> { (ResourceType.EPub, "ePub_id"), (ResourceType.Course, "course_id"), (ResourceType.EPub, "ePub_id") }; foreach (var imageInfo in imageInfos) { var postResult = await _controller.PostImage( imageFile, imageInfo.sourceType.ToString(), imageInfo.sourceId ); Assert.IsType <CreatedAtActionResult>(postResult.Result); } var getResult = await _controller.GetImagesBySource(ResourceType.EPub.ToString(), imageInfos[0].sourceId); List <Image> imagesBySource = getResult.Value.ToList(); Assert.Equal(2, imagesBySource.Count); Assert.Equal(imageInfos[0].sourceType, imagesBySource[0].SourceType); Assert.Equal(imageInfos[0].sourceId, imagesBySource[0].SourceId); Assert.Equal(imageInfos[2].sourceType, imagesBySource[1].SourceType); Assert.Equal(imageInfos[2].sourceId, imagesBySource[1].SourceId); }