public void ShowsOnlyMessagesFromTheFollowedUser() { var aliceFollowedBob = new UserFollowed("Alice", "Bob"); var bobsPost = new MessagePosted("Bob", "A message from Bob", fakeClock.HypoteticalNow); wallPresenter.Handle(aliceFollowedBob); wallPresenter.Handle(bobsPost); var alicesWall = GetWallFor(userName); Assert.That(alicesWall[0], Is.EqualTo("Bob - A message from Bob (0 seconds ago)")); }
public void AggregatesTheirMessagesToTheSourceUsersWall() { var alicesPost = new MessagePosted("Alice", "A message from Alice", fakeClock.HypoteticalNow); var aliceFollowedBob = new UserFollowed("Alice", "Bob"); var bobsPost = new MessagePosted("Bob", "A message from Bob", fakeClock.HypoteticalNow.AddSeconds(1)); wallPresenter.Handle(alicesPost); wallPresenter.Handle(aliceFollowedBob); wallPresenter.Handle(bobsPost); var alicesWall = GetWallFor(userName); Assert.That(alicesWall[0], Is.EqualTo("Alice - A message from Alice (0 seconds ago)")); Assert.That(alicesWall[1], Is.EqualTo("Bob - A message from Bob (1 second ago)")); }
public void ShowsMessagesFromMultipleFollowedUsers() { var aliceFollowedBob = new UserFollowed("Alice", "Bob"); var aliceFollowedCharlie = new UserFollowed("Alice", "Charlie"); var bobsPost = new MessagePosted("Bob", "A message from Bob", fakeClock.HypoteticalNow); var charliePost = new MessagePosted("Charlie", "A message from Charlie", fakeClock.HypoteticalNow); wallPresenter.Handle(aliceFollowedBob); wallPresenter.Handle(aliceFollowedCharlie); wallPresenter.Handle(bobsPost); wallPresenter.Handle(charliePost); var alicesWall = GetWallFor(userName); Assert.That(alicesWall[0], Is.EqualTo("Bob - A message from Bob (0 seconds ago)")); Assert.That(alicesWall[1], Is.EqualTo("Charlie - A message from Charlie (0 seconds ago)")); }
internal void SetLastMessageId(long ChatId, int MessageId) { if (LastMessageIds.ContainsKey(ChatId)) { LastMessageIds[ChatId] = MessageId; } else { LastMessageIds.Add(ChatId, MessageId); } try { if (Machines.ContainsKey(Convert.ToInt32(ChatId))) { Machines[Convert.ToInt32(ChatId)].SetLastMessageId(MessageId); } } catch { } MessagePosted?.Invoke(ChatId, MessageId); }
/// <summary> /// Posts a message. /// </summary> /// <param name="message">The message.</param> public void PostMessage(string message) { MessagePosted?.Invoke(this, new MessagePostedEventArgs(_tag, message)); }
protected virtual void OnMessagePosted(NntpMessage e) { MessagePosted?.Invoke(this, e); }
public void Handle(PostMessage message) { var messagePosted = new MessagePosted(message.UserName, message.Message, DateTime.Now); bus.Publish(messagePosted); }