public void apply_a_filter_on_fixture_graph_at_the_namespace_level() { var filter = new FixtureFilter() { Name = "ST.Grammars", Type = FilterType.Namespace }; var composite = new CompositeFilter <FixtureGraph>(); filter.Apply(composite); composite.Matches(new FixtureGraph() { FixtureNamespace = "ST.Grammars" }).ShouldBeTrue(); composite.Matches(new FixtureGraph() { FixtureNamespace = "ST.Grammars.More" }).ShouldBeTrue(); composite.Matches(new FixtureGraph() { FixtureNamespace = "More.ST.Grammars.More" }).ShouldBeFalse(); composite.Matches(new FixtureGraph() { FixtureNamespace = "SomethingDifferent" }).ShouldBeFalse(); }
public void match_with_includes_and_no_excludes() { var filter = new CompositeFilter<string>(); filter.Includes += x => x == "a"; filter.Matches("a").ShouldBeTrue(); filter.Matches("b").ShouldBeFalse(); }
public void match_with_includes_and_no_excludes() { var filter = new CompositeFilter <string>(); filter.Includes += x => x == "a"; filter.Matches("a").ShouldBeTrue(); filter.Matches("b").ShouldBeFalse(); }
public void apply_the_always_filter() { var composite = new CompositeFilter <Type>(); FixtureFilter.All().Apply(composite); composite.Matches(typeof(MathFixture)).ShouldBeTrue(); composite.Matches(typeof(AnotherFixture)).ShouldBeTrue(); composite.Matches(this.GetType()).ShouldBeTrue(); }
public void TypeMethodPolicyTester() { var filter = new CompositeFilter <MethodInfo>(); var policy = new TypeMethodPolicy <IRouter>(filter); policy.Include(x => x.Go()); filter.Matches(ReflectionHelper.GetMethod <Router1>(x => x.Go())).ShouldBeTrue(); filter.Matches(ReflectionHelper.GetMethod <Router1>(x => x.CanGo())).ShouldBeFalse(); }
public void match_with_matching_include_and_not_matching_exclude() { var filter = new CompositeFilter<string>(); filter.Includes += x => x.StartsWith("a"); filter.Excludes += x => x == "a"; filter.Matches("a").ShouldBeFalse(); filter.Matches("abc").ShouldBeTrue(); filter.Matches("b").ShouldBeFalse(); }
public void match_with_matching_include_and_not_matching_exclude() { var filter = new CompositeFilter <string>(); filter.Includes += x => x.StartsWith("a"); filter.Excludes += x => x == "a"; filter.Matches("a").ShouldBeFalse(); filter.Matches("abc").ShouldBeTrue(); filter.Matches("b").ShouldBeFalse(); }
public void match_with_no_includes_an_no_excludes() { var filter = new CompositeFilter <string>(); filter.Excludes.DoesNotMatchAny("a").ShouldBeTrue(); filter.Matches("a").ShouldBeTrue(); }
public void apply_a_filter_on_fixture_graph_at_the_type_level() { var filter = new FixtureFilter { Name = typeof(MathFixture).GetFixtureAlias(), Type = FilterType.Fixture }; var composite = new CompositeFilter <FixtureGraph>(); filter.Apply(composite); composite.Matches(new FixtureGraph("Math")).ShouldBeTrue(); composite.Matches(new FixtureGraph("Math1")).ShouldBeFalse(); composite.Matches(new FixtureGraph("SomethingElse")).ShouldBeFalse(); }
public void Start() { if (!Conventions.Any()) { throw new InvalidOperationException($"There are no {nameof(IRegistrationConvention)}'s in this scanning operation. "); } _typeFinder = TypeRepository.FindTypes(_assemblies, type => _filter.Matches(type)); }
public void apply_a_filter_at_the_type_level() { var filter = new FixtureFilter { Name = typeof(MathFixture).GetFixtureAlias(), Type = FilterType.Fixture }; var composite = new CompositeFilter <Type>(); filter.Apply(composite); composite.Matches(typeof(MathFixture)).ShouldBeTrue(); composite.Matches(typeof(AnotherFixture)).ShouldBeFalse(); composite.Matches(GetType()).ShouldBeFalse(); }
public void apply_a_filter_at_namespace_level() { var filter = new FixtureFilter { Name = typeof(MathFixture).Namespace, Type = FilterType.Namespace }; var composite = new CompositeFilter <Type>(); filter.Apply(composite); composite.Matches(typeof(MathFixture)).ShouldBeTrue(); typeof(AnotherFixture).IsInNamespace(typeof(MathFixture).Namespace); composite.Matches(typeof(AnotherFixture)).ShouldBeTrue(); composite.Matches(GetType()).ShouldBeFalse(); }
Task ISendObserver.PostSend <T>(SendContext <T> context) { if (!_filter.Matches(context)) { return(TaskUtil.Completed); } var metadata = _metadataFactory.CreateAuditMetadata(context); return(_store.StoreMessage(context.Message, metadata)); }
public ActionCallCandidateExpression ForTypesOf <T>(Action <TypeMethodPolicy <T> > configure) { _matcher.TypeFilters.Includes += type => type.IsConcreteTypeOf <T>(); var filter = new CompositeFilter <MethodInfo>(); var policy = new TypeMethodPolicy <T>(filter); configure(policy); _matcher.MethodFilters.Excludes += call => call.HandlerType.IsConcreteTypeOf <T>() && !filter.Matches(call.Method); return(this); }
private void readFixtures(TestContext context) { _observer.RecordStatus("Discovering and filtering fixtures"); var fixtureConfiguration = context.Container.Model.For <IFixture>(); var instanceRefs = fixtureConfiguration.Instances.Where(i => _filter.Matches(i.ConcreteType)); FixtureCount = instanceRefs.Count(); instanceRefs.Each(readInstance); _library.AllFixtures = fixtureConfiguration.Instances.Select(x => new FixtureDto { Fullname = x.ConcreteType.FullName, Name = x.ConcreteType.GetFixtureAlias(), Namespace = x.ConcreteType.Namespace }).ToArray(); }
public Task PreConsume <T>(ConsumeContext <T> context) where T : class { if (!_filter.Matches(context)) { return(TaskUtil.Completed); } var metadata = _metadataFactory.CreateAuditMetadata(context); var message = context.Message; if (context.CorrelationId is null) { throw new InvalidOperationException(); } var pacoca = _mapper.Map <IAuditEvent>(message); return(context.Publish <IAuditEvent>(pacoca)); }
internal async Task <HandlerCall[]> FindCalls(JasperOptionsBuilder registry) { if (_conventionalDiscoveryDisabled) { return(_explicitTypes.SelectMany(actionsFromType).ToArray()); } if (registry.ApplicationAssembly == null) { return(new HandlerCall[0]); } // TODO -- need to expose the module assemblies off of this var types = await TypeRepository.FindTypes(registry.ApplicationAssembly, TypeClassification.Concretes | TypeClassification.Closed, type => _typeFilters.Matches(type)) .ConfigureAwait(false); return(types .Where(x => !x.HasAttribute <JasperIgnoreAttribute>()) .Concat(_explicitTypes) .Distinct() .SelectMany(actionsFromType).ToArray()); }
public bool AppliesTo(AssetFile file) { return(_filter.Matches(file)); }
public void TypeMethodPolicyTester() { var filter = new CompositeFilter<MethodInfo>(); var policy = new TypeMethodPolicy<IRouter>(filter); policy.Include(x => x.Go()); filter.Matches(ReflectionHelper.GetMethod<Router1>(x => x.Go())).ShouldBeTrue(); filter.Matches(ReflectionHelper.GetMethod<Router1>(x => x.CanGo())).ShouldBeFalse(); }
public void match_with_no_includes_an_no_excludes() { var filter = new CompositeFilter<string>(); filter.Excludes.DoesNotMatcheAny("a").ShouldBeTrue(); filter.Matches("a").ShouldBeTrue(); }
public bool Matches(IConsumerRegistration registration) { return(_filter.Matches(registration.ConsumerType)); }
public void specify_a_filter_by_action_call() { expression.WhenCallMatches(call => call == action1); filter.Matches(action1).ShouldBeTrue(); filter.Matches(action2).ShouldBeFalse(); }
private void addInputs(IRouteDefinition route, ActionCall call) { call.InputType().GetProperties() .Where(p => _propertyFilters.Matches(new InputPropertyForAction(call, p))) .Each(prop => _propertyAlterations.Alter(route, prop)); }
internal async Task <HandlerCall[]> FindCalls(JasperOptions options) { if (_conventionalDiscoveryDisabled) { return(_explicitTypes.SelectMany(actionsFromType).ToArray()); } if (options.ApplicationAssembly == null) { return(new HandlerCall[0]); } _assemblies.Add(options.ApplicationAssembly); var types = await TypeRepository.FindTypes(_assemblies, TypeClassification.Concretes | TypeClassification.Closed, type => _typeFilters.Matches(type)) .ConfigureAwait(false); return(types .Where(x => !x.HasAttribute <JasperIgnoreAttribute>()) .Concat(_explicitTypes) .Distinct() .SelectMany(actionsFromType).ToArray()); }
internal async Task <HandlerCall[]> FindCalls(IJasperRegistry registry) { if (registry.ApplicationAssembly == null) { return(new HandlerCall[0]); } // TODO -- need to expose the module assemblies off of this var types = await TypeRepository.FindTypes(registry.ApplicationAssembly, TypeClassification.Concretes | TypeClassification.Closed, type => _typeFilters.Matches(type)) .ConfigureAwait(false); return(types.Where(x => !x.HasAttribute <NotHandlerAttribute>()).SelectMany(actionsFromType).ToArray()); }