Skip to content

Instantly share code, notes, and snippets.

@stijnmoreels
Created January 30, 2024 06:02
Show Gist options
  • Select an option

  • Save stijnmoreels/3736edaf8f3e40868dc7120be06ac171 to your computer and use it in GitHub Desktop.

Select an option

Save stijnmoreels/3736edaf8f3e40868dc7120be06ac171 to your computer and use it in GitHub Desktop.
[Fact]
public void Delete_WithMessageId_ShouldDeleteMessage()
{
// Arrange
var messageId = Guid.NewGuid().ToString();
var repo = new Mock<IMessageRepository>();
repo.Setup(r => r.DeleteMessage(messageId)).Returns(1);
var cache = new Mock<IMessageCache>();
cache.Setup(c => c.Get(messageId)).Returns(Cache.NotInCache);
var notifier = new Mock<IMessageNotifier>();
notifier.Setup(n => n.NewMessage(messageId))
.Returns(new NotifyResult(NotifyType.Notified))
var service = new MessageService(repo.Object, cache.Object, notifier.Object);
// Act
service.DeleteMessageById(messageId);
// Assert
repo.Verify(r => r.DeleteMessage(messageId), Times.Once);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment