public async Task Should_Mark_All_Notifications_Read() { int result = 0; User sender = new User((Nickname)"sender", (FullName)"sender user", Password.Create("password").Value, (Email)"*****@*****.**", "my bio"); User recipient = new User((Nickname)"recipient", (FullName)"recipient user", Password.Create("password").Value, (Email)"*****@*****.**", "my bio"); var not1 = new Notification(sender, recipient, "Notification 1"); var not2 = new Notification(sender, recipient, "Notification 2"); var not3 = new Notification(sender, recipient, "Notification 3"); using (var session = _testFixture.OpenSession(_output)) { await session.SaveAsync(sender); await session.SaveAsync(recipient); await session.SaveAsync(not1); await session.SaveAsync(not2); await session.SaveAsync(not3); await session.FlushAsync(); } var command = new MarkAllUserNotificationsReadCommand(recipient.ID); using (var session = _testFixture.OpenSession(_output)) { var sut = new MarkAllUserNotificationsReadCommandHandler(session, Log.Logger); result = await sut.Handle(command, default); } result.Should().Be(3); }
public async Task <IActionResult> Index() { // Loads all unread notifications var query = new NotificationsQuery(User.GetIdentifier(), false); var notifications = await _dispatcher.Send(query); // Marks all unread notifications as read var markAllAsReadCommand = new MarkAllUserNotificationsReadCommand(User.GetIdentifier()); await _dispatcher.Send(markAllAsReadCommand); return(View(notifications)); }