Exemple #1
0
        public void AddNotificationsTo_updates_target_list()
        {
            var aggregateNotificationList = 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", "message3 for param1")
                                         .AddNotification("param1", "message4 for param1")
                                         .AddNotification("param2", "message2 for param2")
                                         .AddNotification("param4", "message1 for param4");

            var aggregateResult = AggregateResult <TestAggregate>
                                  .Fail(aggregateNotificationList);

            aggregateResult.AddNotificationsTo(targetNotificationList);

            targetNotificationList.ShouldSatisfyAllConditions(
                () => targetNotificationList["param1"].Count.ShouldBe(4),
                () => targetNotificationList["param2"].Count.ShouldBe(2),
                () => targetNotificationList["param3"].Count.ShouldBe(1),
                () => targetNotificationList["param4"].Count.ShouldBe(1),
                () => targetNotificationList["param1"].Any(n => n.Message == "message2 for param1").ShouldBeTrue(),
                () => targetNotificationList["param1"].Any(n => n.Message == "message4 for param1").ShouldBeTrue());
        }
Exemple #2
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));
        }
Exemple #3
0
        public void Construct_from_message_string_populates_object()
        {
            var notificationList = new NotificationList("param1", "You screwed up.");

            notificationList.ShouldSatisfyAllConditions(
                () => notificationList.Count.ShouldBe(1),
                () => notificationList["param1"].First().Message.ShouldBe("You screwed up.")
                );
        }
Exemple #4
0
        public void Construct_from_Notification_adds_notification()
        {
            var notification = new Notification("hello1");

            var notificationList = new NotificationList("param", notification);

            notificationList.ShouldSatisfyAllConditions(
                () => notificationList.Count.ShouldBe(1),
                () => notificationList["param"].First().ShouldBe(notification)
                );
        }