Skip to content

Instantly share code, notes, and snippets.

@stijnmoreels
Created January 30, 2024 06:02
Show Gist options
  • Save stijnmoreels/932f9df1d7f6ba91c5927bba3975bd91 to your computer and use it in GitHub Desktop.
Save stijnmoreels/932f9df1d7f6ba91c5927bba3975bd91 to your computer and use it in GitHub Desktop.
[Fact]
public void Delete_WithMessageId_ShouldDeleteMessage()
{
// Arrange
Message[] leftOverMessages = CreateMessages();
Message targetMessage = CreateMessage();
var repo = new InMemoryMessageRepository(leftOverMessages.Append(targetMessage));
var service = CreateMessageService(repo);
// Act
DeleteResult result = service.DeleteMessageById(targetMessage.Id);
// Assert
Assert.Equal(DeleteResult.Deleted, result);
Assert.Equal(targetMessage.Id, result.Value);
Message[] actual = repo.GetMessages();
Assert.DoesNotContain(targetMessage, actual);
Assert.All(leftOverMessages, msg => Assert.Contains(msg, actual));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment