Ejemplo n.º 1
0
        public void TrueFilterConstructorTest()
        {
            TrueFilter target = new TrueFilter();

            Assert.IsNotNull(target);
            Assert.IsInstanceOfType(target, typeof(TrueFilter));
        }
Ejemplo n.º 2
0
        public static Filter GetFilter(AmqpFilter amqpFilter)
        {
            Filter sqlFilter;

            if (amqpFilter.DescriptorCode == AmqpSqlFilter.Code)
            {
                sqlFilter = new SqlFilter(((AmqpSqlFilter)amqpFilter).Expression);
            }
            else if (amqpFilter.DescriptorCode == AmqpTrueFilter.Code)
            {
                sqlFilter = new TrueFilter();
            }
            else if (amqpFilter.DescriptorCode != AmqpFalseFilter.Code)
            {
                if (amqpFilter.DescriptorCode != AmqpCorrelationFilter.Code)
                {
                    throw new NotSupportedException();
                }
                sqlFilter = new CorrelationFilter(((AmqpCorrelationFilter)amqpFilter).CorrelationId);
            }
            else
            {
                sqlFilter = new FalseFilter();
            }
            return(sqlFilter);
        }
Ejemplo n.º 3
0
        public void IsMatchTest()
        {
            TrueFilter    target  = new TrueFilter();
            SyslogMessage message = new SyslogMessage(null, "logbus.unina.it", SyslogFacility.Kernel,
                                                      SyslogSeverity.Notice, "Don't care about me");

            bool expected = true;
            bool actual;

            actual = target.IsMatch(message);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 4
0
        public static Filter GetFilter(AmqpFilterCodec amqpFilter)
        {
            Filter filter;

            switch (amqpFilter.DescriptorCode)
            {
            case AmqpSqlFilterCodec.Code:
                var amqpSqlFilter = (AmqpSqlFilterCodec)amqpFilter;
                filter = new SqlFilter(amqpSqlFilter.Expression);
                break;

            case AmqpTrueFilterCodec.Code:
                filter = new TrueFilter();
                break;

            case AmqpFalseFilterCodec.Code:
                filter = new FalseFilter();
                break;

            case AmqpCorrelationFilterCodec.Code:
                var amqpCorrelationFilter = (AmqpCorrelationFilterCodec)amqpFilter;
                var correlationFilter     = new CorrelationFilter
                {
                    CorrelationId    = amqpCorrelationFilter.CorrelationId,
                    MessageId        = amqpCorrelationFilter.MessageId,
                    To               = amqpCorrelationFilter.To,
                    ReplyTo          = amqpCorrelationFilter.ReplyTo,
                    Label            = amqpCorrelationFilter.Label,
                    SessionId        = amqpCorrelationFilter.SessionId,
                    ReplyToSessionId = amqpCorrelationFilter.ReplyToSessionId,
                    ContentType      = amqpCorrelationFilter.ContentType
                };

                foreach (var property in amqpCorrelationFilter.Properties)
                {
                    correlationFilter.Properties.Add(property.Key.Key.ToString(), property.Value);
                }

                filter = correlationFilter;
                break;

            default:
                throw new NotSupportedException($"Unknown filter descriptor code: {amqpFilter.DescriptorCode}");
            }

            return(filter);
        }
Ejemplo n.º 5
0
        private static async Task AddBooleanFilters(bool _catch)
        {
            var rules = await salesCancelSubscriptionClient.GetRulesAsync();

            if (_catch)
            {
                if (!rules.Any(r => r.Name == "CatchAll"))
                {
                    var catchAllFilter = new TrueFilter();
                    await salesCancelSubscriptionClient.AddRuleAsync("CatchAll", catchAllFilter);
                }
            }
            else
            {
                if (!rules.Any(r => r.Name == "CatchNothing"))
                {
                    var catchNothingFilter = new FalseFilter();
                    await salesCancelSubscriptionClient.AddRuleAsync("CatchNothing", catchNothingFilter);
                }
            }
        }
Ejemplo n.º 6
0
        public void filterTest()
        {
            OrFilter target = new OrFilter();
            FilterBase
                f1 = new TrueFilter(),
                f2 = new NotFilter {
                filter = new FalseFilter()
            },
                f3 = new MessageRegexMatchFilter {
                pattern = "FFDA"
            },
                f4 = new FacilityEqualsFilter {
                facility = SyslogFacility.Security
            };

            target.filter = new FilterBase[] { f1, f2, f3, f4 };

            Assert.AreEqual(target.filter[0], f1);
            Assert.IsInstanceOfType(target.filter[1], typeof(NotFilter));
            Assert.IsInstanceOfType(target.filter[3], typeof(FacilityEqualsFilter));
            Assert.AreEqual(((FacilityEqualsFilter)target.filter[3]).facility, SyslogFacility.Security);
        }
Ejemplo n.º 7
0
        internal static QueryFilter GetFlowConversationFilter(BaseFolderId folderId, MailboxSession mailboxSession)
        {
            QueryFilter queryFilter3;

            if (folderId == null)
            {
                QueryFilter queryFilter  = new ComparisonFilter(ComparisonOperator.Equal, StoreObjectSchema.ParentItemId, mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox));
                QueryFilter queryFilter2 = new ComparisonFilter(ComparisonOperator.Equal, StoreObjectSchema.ParentItemId, mailboxSession.GetDefaultFolderId(DefaultFolderType.SentItems));
                queryFilter3 = new OrFilter(new QueryFilter[]
                {
                    queryFilter,
                    queryFilter2
                });
            }
            else
            {
                queryFilter3 = new TrueFilter();
            }
            return(new AndFilter(new QueryFilter[]
            {
                queryFilter3,
                GetFlowConversation.ItemClassFilter
            }));
        }
Ejemplo n.º 8
0
        public static void Run(string loc, string[] args)
        {
            MainArgs ma       = MainArgs.ValueOf(args);
            string   excludes = ma.Get("exclude", null);
            string   includes = ma.Get("include", null);
            string   outfile  = ma.Get("out", "TestResult.xml");

            CoreExtensions.Host.InitializeService();
            TestSuiteBuilder builder          = new TestSuiteBuilder();
            TestPackage      testPackage      = new TestPackage(loc);
            RemoteTestRunner remoteTestRunner = new RemoteTestRunner();

            remoteTestRunner.Load(testPackage);
            TestSuite          suite    = builder.Build(testPackage);
            TestSuite          root     = suite.Tests[0] as TestSuite;
            List <TestFixture> fixtures = new List <TestFixture>();

            ScanFixtures(root, fixtures);
            Console.WriteLine("--------------- {0} TextFixtures --------------- \n", fixtures.Count);
            //TestName testName = ((TestMethod) ((TestFixture) test.Tests[0]).Tests[0]).MethodName;

            ITestFilter filter     = null;
            bool        hasInclude = !string.IsNullOrEmpty(includes);
            bool        hasExclude = !string.IsNullOrEmpty(excludes);

            if (hasInclude)
            {
                if (hasExclude)
                {
                    // incldue+exclude; exclude first
                    filter =
                        new AndFilter(new ITestFilter[]
                                      { new NotFilter(new CategoryFilter(excludes.Split(','))), new SimpleNameFilter(includes.Split(',')), });
                }
                else
                {
                    // include
                    filter = new SimpleNameFilter(includes.Split(','));
                }
            }
            else // no include
            {
                if (hasExclude)
                {
                    // Only exclude
                    filter = new NotFilter(new CategoryFilter(excludes.Split(',')));
                }
                else
                {
                    // none
                    filter = new TrueFilter();
                }
            }

            int              succCnt = 0, failCnt = 0, errorCnt = 0, assertCnt = 0;
            TestResult       tr       = new TestResult(new TestName());
            RunEventListener eventLsn = new RunEventListener();

            foreach (TestFixture tf in fixtures)
            {
                TestResult    result = tf.Run(eventLsn, filter);
                FixtureResult fr     = null;
                if (result.Results != null)
                {
                    fr         = new FixtureResult(result);
                    succCnt   += fr.succCnt;
                    failCnt   += fr.failCnt;
                    errorCnt  += fr.errorCnt;
                    assertCnt += fr.assertCnt;
                    Console.WriteLine("  Done: " + fr.ToString());
                }
                else
                {
                    Console.WriteLine("  Done: no result.");
                }
                tr.AddResult(result);
            }
            if (failCnt + errorCnt == 0)
            {
                Console.WriteLine(
                    @"=========================================
Test Success! Cases: {0}, asserts: {1}
=========================================",
                    succCnt, assertCnt);
            }
            else
            {
                Console.WriteLine(
                    @"=================================================================================
 Test with errors: Cases: {0}, asserts: {4}, Succ: {1}, fail:{2}, error: {3}
=================================================================================",
                    succCnt + errorCnt + failCnt, succCnt, failCnt, errorCnt, assertCnt);
            }
            XmlResultWriter w = new XmlResultWriter(outfile);

            w.SaveTestResult(tr);
            Console.WriteLine("Result save to: {0}", outfile);
        }
Ejemplo n.º 9
0
        public void Constructor_TypeIsCorrect()
        {
            var filter = new TrueFilter();

            Assert.That(filter.Type, Is.EqualTo("true"));
        }