示例#1
0
        public void Repository_should_filter_by_execution_duration()
        {
            var filter = RepositoryMessagesFilter.Create().WithExecutionDurationAbove(100);
            var msg    = new MessageRecord
            {
                ExecutionDuration = 200,
            };

            Assert.True(filter.IsMatch(msg));
            msg.ExecutionDuration = 99;
            Assert.False(filter.IsMatch(msg));
        }
示例#2
0
        public void Repository_should_filter_by_type()
        {
            var filter   = RepositoryMessagesFilter.Create().WithType(MessageContextConstants.MessageTypeCommand);
            var msgquery = new MessageRecord
            {
                Type = MessageContextConstants.MessageTypeQuery,
            };

            Assert.False(filter.IsMatch(msgquery));

            filter = filter.WithType(MessageContextConstants.MessageTypeQuery);
            Assert.True(filter.IsMatch(msgquery));
        }
示例#3
0
        public void Repository_should_filter_by_content_type()
        {
            var filter = RepositoryMessagesFilter.Create()
                         .WithIncludeContentType(new Regex(@".(C|c)orrectCommand$"))
                         .WithExcludeContentType(new Regex(@".IncorrectCommand$"));
            var msg = new MessageRecord
            {
                ContentType = "Saritasa.Demo.IncorrectCommand",
            };

            Assert.False(filter.IsMatch(msg));

            msg.ContentType = "Saritasa.Demo.CorrectCommand";
            Assert.True(filter.IsMatch(msg));

            filter = filter.WithExcludeContentType(new Regex(@"Command"));
            Assert.False(filter.IsMatch(msg));
        }
示例#4
0
        public void Repository_should_filter_by_status()
        {
            // Arrange
            var filter = RepositoryMessagesFilter.Create().WithStatus(ProcessingStatus.Completed);
            var msg1   = new MessageRecord
            {
                Status = ProcessingStatus.Failed,
            };

            // Act & assert
            Assert.False(filter.IsMatch(msg1));
            var msg2 = new MessageRecord
            {
                Status = ProcessingStatus.Completed,
            };

            Assert.True(filter.IsMatch(msg2));
            filter = filter.WithStatus(ProcessingStatus.Failed);
            Assert.True(filter.IsMatch(msg1));
        }