Untitled
unknown
plain_text
a year ago
920 B
5
Indexable
[Fact]
public async Task TakePhotoAsync_WhenPhotoIsCaptured_ShouldSavePhoto()
{
// Arrange
var mockFileResult = new Mock<FileResult>();
var mockStream = new MemoryStream(new byte[] { 1, 2, 3 });
mockFileResult
.Setup(x => x.OpenReadAsync())
.ReturnsAsync(mockStream);
_mockMediaPickerService
.Setup(x => x.CapturePhotoAsync())
.ReturnsAsync(mockFileResult.Object);
_mockPhotoStorageService
.Setup(x => x.SavePhotoAsync(It.IsAny<Stream>(), It.IsAny<string>()))
.ReturnsAsync("/path/to/saved/photo.png");
// Act
var result = await _cameraService.TakePhotoAsync();
// Assert
Assert.Equal("/path/to/saved/photo.png", result);
_mockPhotoStorageService.Verify(x => x.SavePhotoAsync(mockStream, "png"), Times.Once);
}Editor is loading...
Leave a Comment