public async Task DismissingDuplicateNotificationAlert_OnlyRemovesRelatedNotification_OnDuplicateRecords() { // This test looks at the edge case where there are three duplicate notifications // pointing to one another in a triangle. Closing one notification should close the duplicate alerts // related to it, but the duplicate alerts between the two other notifications should remain // Arrange var alert1To2 = AlertHelper.CreateOpenDuplicateAlert(1, 2, 101); var alert1To3 = AlertHelper.CreateOpenDuplicateAlert(1, 3, 102); var alert2To1 = AlertHelper.CreateOpenDuplicateAlert(2, 1, 103); var alert2To3 = AlertHelper.CreateOpenDuplicateAlert(2, 3, 104); var alert3To1 = AlertHelper.CreateOpenDuplicateAlert(3, 1, 105); var alert3To2 = AlertHelper.CreateOpenDuplicateAlert(3, 2, 106); _mockAlertRepository .Setup(s => s.GetAllOpenAlertsByNotificationId(1)) .Returns(Task.FromResult(new List <Alert> { alert1To2, alert1To3 })); _mockAlertRepository .Setup(s => s.GetAllOpenAlertsByNotificationId(2)) .Returns(Task.FromResult(new List <Alert> { alert2To1, alert2To3 })); _mockAlertRepository .Setup(s => s.GetAllOpenAlertsByNotificationId(3)) .Returns(Task.FromResult(new List <Alert> { alert3To1, alert3To2 })); // Act await _alertService.DismissAllOpenAlertsForNotification(1); // Assert AssertAlertClosedRecently(alert1To2); AssertAlertClosedRecently(alert2To1); AssertAlertClosedRecently(alert1To3); AssertAlertClosedRecently(alert3To1); AssertAlertNotClosed(alert2To3); AssertAlertNotClosed(alert3To2); }