Example #1
0
        public void Aggregate_ListMessagesCountIsZero_ReturnFalse()
        {
            var notificationAggregatorsValidator = new NotificationAggregatorsValidator();
            var listMessages = new List <NotificationMessage>();

            notificationAggregatorsValidator.SetAggregators(_aggregator);

            notificationAggregatorsValidator.AggregateIfPossible(listMessages, _message).Should().BeFalse();
        }
Example #2
0
        public void Aggregate_MessageFieldsIsNull_ReturnFalse()
        {
            var notificationAggregatorsValidator = new NotificationAggregatorsValidator();
            var message = new FieldsContainer();

            notificationAggregatorsValidator.SetAggregators(_aggregator);

            notificationAggregatorsValidator.AggregateIfPossible(null, message).Should().BeFalse();
        }
Example #3
0
        public void ToString_WithAggregators_ReturnString()
        {
            var notificationAggregatorsValidator = new NotificationAggregatorsValidator();

            const string expected = "Id: 0, \r\nAggregators: 1: {\r\n	MessageAggregateColumnNames: [Message,MessageType,Exception]\r\n}\r\n";

            notificationAggregatorsValidator.SetAggregators(_aggregator);

            notificationAggregatorsValidator.ToString().Should().Match(expected);
        }
Example #4
0
        public void Aggregate_AggregationColumnNameListaggregationColumnNameListIsNull_ReturnFalse()
        {
            var notificationAggregatorsValidator = new NotificationAggregatorsValidator();
            var listMessages = new List <NotificationMessage> {
                new NotificationMessage()
            };
            var aggregator = new Aggregators
            {
                AggregationParams = new[] {
                    new AggregationInfo
                    {
                        MessageAggregateColumnNames = new[] { "ApplicationName", "MessageType", "Exception" }
                    }
                }
            };

            notificationAggregatorsValidator.SetAggregators(aggregator);

            notificationAggregatorsValidator.AggregateIfPossible(listMessages, _message).Should().BeFalse();
        }
Example #5
0
        public void Aggregate_MessagesToAgggregateIncrementCounter_ReturnTrueAndThreeAggregateMessages()
        {
            var notificationAggregatorsValidator = new NotificationAggregatorsValidator();
            var listMessages = new List <NotificationMessage>
            {
                new NotificationMessage
                {
                    Fields = new List <FieldInfo>
                    {
                        new FieldInfo
                        {
                            Name  = "Message",
                            Value = "Exception"
                        }
                    }
                }
            };
            var expected = new List <NotificationMessage>
            {
                new NotificationMessage
                {
                    Fields = new List <FieldInfo>
                    {
                        new FieldInfo
                        {
                            Name  = "Message",
                            Value = "Exception"
                        }
                    },
                    AggregatedMessagesCount = 2
                }
            };

            notificationAggregatorsValidator.SetAggregators(_aggregator);

            notificationAggregatorsValidator.AggregateIfPossible(listMessages, _message).Should().BeTrue();

            listMessages.Should().BeEquivalentTo(expected);
        }
Example #6
0
        public void Aggregate_MessagesToAgggregateAddNewCounter_ReturnTrue()
        {
            var notificationAggregatorsValidator = new NotificationAggregatorsValidator();
            var listMessages = new List <NotificationMessage>
            {
                new NotificationMessage
                {
                    Fields = new List <FieldInfo>
                    {
                        new FieldInfo
                        {
                            Name  = "Message",
                            Value = "Exception"
                        }
                    }
                }
            };

            notificationAggregatorsValidator.SetAggregators(_aggregator);

            notificationAggregatorsValidator.AggregateIfPossible(listMessages, _message).Should().BeTrue();
        }
Example #7
0
        public void Aggregate_NoMessagesToAgggregate_ReturnFalse()
        {
            var notificationAggregatorsValidator = new NotificationAggregatorsValidator();
            var listMessages = new List <NotificationMessage>
            {
                new NotificationMessage
                {
                    Fields = new List <FieldInfo>
                    {
                        new FieldInfo
                        {
                            Name  = "Message",
                            Value = "Lorem ipsum"
                        }
                    }
                }
            };

            notificationAggregatorsValidator.SetAggregators(_aggregator);

            notificationAggregatorsValidator.AggregateIfPossible(listMessages, _message).Should().BeFalse();
        }
Example #8
0
        public void Aggregate_AggregatorsIsNull_ReturnFalse()
        {
            var notificationAggregatorsValidator = new NotificationAggregatorsValidator();

            notificationAggregatorsValidator.AggregateIfPossible(null, null).Should().BeFalse();
        }
Example #9
0
        public void ToString_WithoutAggregators_ReturnNONE()
        {
            var notificationAggregatorsValidator = new NotificationAggregatorsValidator();

            notificationAggregatorsValidator.ToString().Should().Match("NONE");
        }