Beispiel #1
0
    public void should_send_the_last_unit_to_children_if_no_unit_matched()
    {
        const string kind = "kind";

        var expected = new UnitId("expected", "expected");

        // --arrange
        var target = new SkipWhileUnit(new UnitPattern(kind));
        var child1 = A.Fake <IBuildChainPattern>();
        var child2 = A.Fake <IBuildChainPattern>();

        target.AddNode(child1);
        target.AddNode(child2);

        // --act
        var chain = new[] { new UnitId(kind, null), new UnitId(kind, null), new UnitId(kind, null), expected }.ToArrayTail();

        target.GatherBuildActions(chain, out var actionBag, 0);

        // --assert
        A.CallTo(
            () => child1.GatherBuildActions(
                An <BuildChain> .That.IsEqualTo(expected.ToArrayTail(), Comparer.OfArrayTail <UnitId>()),
                out actionBag,
                An <int> ._))
        .MustHaveHappenedOnceAndOnly();

        A.CallTo(
            () => child2.GatherBuildActions(
                An <BuildChain> .That.IsEqualTo(expected.ToArrayTail(), Comparer.OfArrayTail <UnitId>()),
                out actionBag,
                An <int> ._))
        .MustHaveHappenedOnceAndOnly();
    }
Beispiel #2
0
    public void should_add_self_weight_to_input_weight()
    {
        const string kind          = "kind";
        const int    patternWeight = 39;
        const int    inputWeight   = 21;

        // --arrange
        var target = new SkipWhileUnit(new UnitPattern(kind), patternWeight);
        var child1 = A.Fake <IBuildChainPattern>();
        var child2 = A.Fake <IBuildChainPattern>();

        target.AddNode(child1);
        target.AddNode(child2);

        // --act
        var chain = new[] { new UnitId(kind, null), new UnitId(kind, null), new UnitId("not" + kind, null) }.ToArrayTail();

        target.GatherBuildActions(chain, out var actionBag, inputWeight);

        // --assert
        A.CallTo(() => child1.GatherBuildActions(An <BuildChain> ._, out actionBag, inputWeight + patternWeight)).MustHaveHappenedOnceAndOnly();
        A.CallTo(() => child2.GatherBuildActions(An <BuildChain> ._, out actionBag, inputWeight + patternWeight)).MustHaveHappenedOnceAndOnly();
    }