Skip to content

Instantly share code, notes, and snippets.

@xplicit
Last active October 28, 2019 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xplicit/957f634cccdbcef3f369026b562f3fe9 to your computer and use it in GitHub Desktop.
Save xplicit/957f634cccdbcef3f369026b562f3fe9 to your computer and use it in GitHub Desktop.
readonly Mock<ILog> log4netMock = new Mock<ILog>();
[Test]
public void SingleSendActionWithException_ErrorLoggedOnce()
{
Smock.Run(context =>
{
// Arrange
context.Setup(() => LogManager.GetLogger(It.IsAny<Type>())).Returns(log4netMock.Object);
var logglyQueue = new LogglyQueue();
// Act
logglyQueue.SendAction(new ActionMessage { Status = Status.Start });
// Assert
log4netMock.Verify(l => l.Error(It.IsAny<object>(), It.IsAny<Exception>()), Times.Once);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment