public void WhenSaveTwoSameMessagesThenOnlyOneIsSaved()
        {
            const string messageA = "MessageA";

            var timelineMessage = new TimelineMessageProjection(_ownerId, _authorId, messageA, MessageId.Generate());

            _repository.Save(timelineMessage);
            _repository.Save(timelineMessage);

            var messagesOfUser = _repository.GetMessagesOfUser(_ownerId).ToList();

            Check.That(messagesOfUser).HasSize(1);
        }
        public void GivenAMessageSavedForSeveralUsersWhenRemoveThisMessageThenRemoveThisMessageOfAllUsers()
        {
            const string messageA = "MessageA";

            var messageId = MessageId.Generate();

            _repository.Save(new TimelineMessageProjection(_ownerId, _authorId, messageA, messageId));
            var message2 = new TimelineMessageProjection(_ownerId, _authorId, messageA, MessageId.Generate());

            _repository.Save(message2);
            var ownerId2 = new UserId("*****@*****.**");

            _repository.Save(new TimelineMessageProjection(ownerId2, _authorId, messageA, messageId));

            _repository.Delete(messageId);

            var messagesOfOwner1 = _repository.GetMessagesOfUser(_ownerId);

            Check.That(messagesOfOwner1).HasSize(1).And.ContainsExactly(message2);
            Check.That(_repository.GetMessagesOfUser(ownerId2)).IsEmpty();
        }
Example #3
0
 public void Save(TimelineMessageProjection messageProjection)
 {
     _messages.Add(messageProjection);
 }