コード例 #1
0
        public void Should_return_result_of_func(bool funcResult)
        {
            var matcher = new FuncMatcher("test", type => funcResult);

            var matchResult = matcher.TryMatch(PersistentTask.Instance);

            Assert.That(matchResult.Matched, Is.EqualTo(funcResult));
        }
コード例 #2
0
        public void Should_match_and_return_results_from_different_matchers()
        {
            var nsMatcher = new NamespaceMatcher("byNamespace", typeof (PersistentTask).Namespace);
            var funcMatcher = new FuncMatcher("byFunc", task => task.GetType() == typeof (LongRunningTask));

            var matcher = new AggregateMatcher(nsMatcher, funcMatcher);

            var namespaceMatch = matcher.TryMatch(PersistentTask.Instance);

            Assert.That(namespaceMatch.Matched, Is.True);
            Assert.That(namespaceMatch.Value, Is.EqualTo("byNamespace"));

            var anotherTask = new LongRunningTask(false);
            var funcMatch = matcher.TryMatch(anotherTask);

            Assert.That(funcMatch.Matched, Is.True);
            Assert.That(funcMatch.Value, Is.EqualTo("byFunc"));
        }