public void should_return_children_merged_actions() { // --arrange var buildStep1 = new LastUnitSequenceMatcher(Match.Type <int>(null)); buildStep1.AddBuildAction(BuildStage.Cache, CreateByReflectionBuildAction.Instance); var singletonAction = new SingletonBuildAction(); var buildStep2 = new AnyUnitSequenceMatcher(); buildStep2.AddBuildAction(BuildStage.Cache, singletonAction); var target = new WildcardUnitSequenceMatcher(Match.Type <string>(null)); target.AddOrGetUnitSequenceMatcher(buildStep1); target.AddOrGetUnitSequenceMatcher(buildStep2); // --act var actual = target.GetBuildActions(new[] { Unit.OfType <string>(), Unit.OfType <int>() }.GetTail(0), 0); // --assert actual.Should().NotBeNull(); // ReSharper disable once PossibleNullReferenceException actual[BuildStage.Cache] .Should() .HaveCount(2) .And .Subject.Select(_ => _.Entity) .Should() .BeEquivalentTo(CreateByReflectionBuildAction.Instance, singletonAction); }
public void should_return_all_merged_actions() { var singletonAction = new SingletonBuildAction(); // --arrange var matchString = new LastUnitSequenceMatcher(Match.Type <string>(null)).AddBuildAction(BuildStage.Cache, CreateByReflectionBuildAction.Instance); var matchAny = new AnyUnitSequenceMatcher().AddBuildAction(BuildStage.Cache, singletonAction); var target = new BuildPlansCollection(); target.Children.Add(matchString); target.Children.Add(matchAny); // --act var actual = target.GetBuildActions(new[] { Unit.OfType <string>() }.AsArrayTail()); // --assert actual[BuildStage.Cache] .Should() .HaveCount(2) .And .Subject.Select(_ => _.Entity) .Should() .Equal(CreateByReflectionBuildAction.Instance, singletonAction); }
/// <summary> /// Used to add some details to build plan of any building unit. E.g. to specify what constructor to use, or register a dependency needed by any type /// in the system. Usually used as a part of other build plan. See <see cref="Building{T}" /> for details. /// </summary> public static Tuner TreatAll([NotNull] this BuildPlansCollection buildPlans) { if (buildPlans == null) { throw new ArgumentNullException(nameof(buildPlans)); } var unitSequenceMatcher = new AnyUnitSequenceMatcher(); return(new Tuner(buildPlans.AddOrGetUnitSequenceMatcher(unitSequenceMatcher))); }
/// <summary> /// Used to add some details to build plan of any building unit in context of currently building one /// </summary> public Tuner TreatAll() { var unitSequenceMatcher = new AnyUnitSequenceMatcher(); return(new Tuner(UnitSequenceMatcher.AddOrGetUnitSequenceMatcher(unitSequenceMatcher))); }