示例#1
0
        public void AddWithAppend_NotificationList_merges_lists()
        {
            var sourceNotificationList = new NotificationList()
                                         .AddNotification("param1", "message1 for param1")
                                         .AddNotification("param1", "message2 for param1")
                                         .AddNotification("param2", "message1 for param2")
                                         .AddNotification("param3", "message1 for param3");

            var targetNotificationList = new NotificationList()
                                         .AddNotification("param1", "message1 for param1") // Intentional duplicate
                                         .AddNotification("param1", "message3 for param1")
                                         .AddNotification("param1", "message4 for param1")
                                         .AddNotification("param2", "message2 for param2")
                                         .AddNotification("param4", "message1 for param4");

            targetNotificationList.AddNotifications(sourceNotificationList);

            targetNotificationList.ShouldSatisfyAllConditions(
                () => targetNotificationList["param1"].Count.ShouldBe(5),
                () => targetNotificationList["param2"].Count.ShouldBe(2),
                () => targetNotificationList["param3"].Count.ShouldBe(1),
                () => targetNotificationList["param4"].Count.ShouldBe(1),
                () => targetNotificationList["param1"].ShouldContain(n => n.Message.Contains("message1 for param1"), 2),
                () => targetNotificationList["param1"].ShouldContain(n => n.Message.Contains("message2 for param1"), 1),
                () => targetNotificationList["param1"].ShouldContain(n => n.Message.Contains("message3 for param1"), 1),
                () => targetNotificationList["param1"].ShouldContain(n => n.Message.Contains("message4 for param1"), 1),
                () => targetNotificationList["param2"].ShouldContain(n => n.Message.Contains("message1 for param2"), 1),
                () => targetNotificationList["param2"].ShouldContain(n => n.Message.Contains("message2 for param2"), 1),
                () => targetNotificationList["param3"].ShouldContain(n => n.Message.Contains("message1 for param3"), 1),
                () => targetNotificationList["param4"].ShouldContain(n => n.Message.Contains("message1 for param4"), 1));
        }