Skip to content

Instantly share code, notes, and snippets.

@TheFo2sh
Last active March 20, 2023 00:42
Show Gist options
  • Save TheFo2sh/bd10587eb1b39aa37fdf3cd129188753 to your computer and use it in GitHub Desktop.
Save TheFo2sh/bd10587eb1b39aa37fdf3cd129188753 to your computer and use it in GitHub Desktop.
public async Task GeneratePdfCommandHandler_Should_Generate_Pdf()
{
// Arrange
var htmlContent = "<html><body><h1>Test</h1></body></html>";
var pdfGenerator = new Mock<IPdfGenerator>();
pdfGenerator.Setup(x => x.GeneratePdfAsync(htmlContent))
.ReturnsAsync(new byte[] { 0x25, 0x50, 0x44, 0x46 });
var commandHandler = new GeneratePdfCommandHandler(pdfGenerator.Object);
var command = new GeneratePdfCommand { HtmlContent = htmlContent };
// Act
await commandHandler.Handle(command);
// Assert
// Check that the PDF generator was called with the correct HTML content
pdfGenerator.Verify(x => x.GeneratePdfAsync(htmlContent), Times.Once);
// Check any other expected behavior
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment