示例#1
0
    public void StillIncludePrivateFundsAfterSwap()
    {
        var selection = new LabelSelectionViewModel(Money.Parse("1.0"));
        var pockets   = new List <Pocket>();

        var privateCoin   = LabelTestExtensions.CreateCoin(0.8m, "", 999);
        var privatePocket = new Pocket((CoinPocketHelper.PrivateFundsText, new CoinsView(new[] { privateCoin })));

        pockets.Add(privatePocket);

        pockets.AddPocket(0.2M, out var pocket2, "Dan");
        pockets.AddPocket(0.1M, out var pocket3, "Lucas");

        selection.Reset(pockets.ToArray());

        var usedCoins = new List <SmartCoin>
        {
            privateCoin
        };

        usedCoins.AddRange(pocket2.Coins);

        selection.SetUsedLabel(usedCoins, 10);
        var output = selection.GetUsedPockets();

        Assert.Contains(privatePocket, output);
        Assert.Contains(pocket2, output);
        Assert.DoesNotContain(pocket3, output);
        Assert.True(selection.EnoughSelected);

        selection.SwapLabel(selection.GetLabel("Lucas"));
        selection.SwapLabel(selection.GetLabel("Lucas"));
        Assert.True(selection.EnoughSelected);
    }
示例#2
0
    public void NotEnoughSelected()
    {
        var selection = new LabelSelectionViewModel(Money.Parse("1.0"));

        var pockets = new List <Pocket>();

        pockets.AddPocket(1.0M, out _, "David");
        pockets.AddPocket(2.0M, out _, "Dan");

        selection.Reset(pockets.ToArray());

        selection.SwapLabel(selection.GetLabel("David"));
        selection.SwapLabel(selection.GetLabel("Dan"));

        Assert.False(selection.EnoughSelected);
    }
示例#3
0
    public void MovesFromWhiteListHighlightsAllLabelsInOtherPocketsThatContainTargetLabel()
    {
        var selection = new LabelSelectionViewModel(Money.Parse("1.0"));

        var pockets = new List <Pocket>();

        pockets.AddPocket(1.0M, out _, "Target", "Dan", "Roland");
        pockets.AddPocket(1.0M, out _, "Target");
        pockets.AddPocket(1.0M, out _, "David", "Adam", "Lucas");
        pockets.AddPocket(1.0M, out _, "Jumar");

        selection.Reset(pockets.ToArray());

        selection.SwapLabel(selection.GetLabel("Target"));

        Assert.Contains(selection.GetLabel("Target"), selection.LabelsBlackList);
        Assert.Contains(selection.GetLabel("Dan"), selection.LabelsBlackList);
        Assert.Contains(selection.GetLabel("Roland"), selection.LabelsBlackList);

        Assert.DoesNotContain(selection.GetLabel("David"), selection.LabelsBlackList);
        Assert.DoesNotContain(selection.GetLabel("Adam"), selection.LabelsBlackList);
        Assert.DoesNotContain(selection.GetLabel("Lucas"), selection.LabelsBlackList);
        Assert.DoesNotContain(selection.GetLabel("Jumar"), selection.LabelsBlackList);

        Assert.DoesNotContain(selection.GetLabel("Target"), selection.LabelsWhiteList);
        Assert.DoesNotContain(selection.GetLabel("Dan"), selection.LabelsWhiteList);
        Assert.DoesNotContain(selection.GetLabel("Roland"), selection.LabelsWhiteList);

        Assert.Contains(selection.GetLabel("David"), selection.LabelsWhiteList);
        Assert.Contains(selection.GetLabel("Adam"), selection.LabelsWhiteList);
        Assert.Contains(selection.GetLabel("Lucas"), selection.LabelsWhiteList);
        Assert.Contains(selection.GetLabel("Jumar"), selection.LabelsWhiteList);
    }
示例#4
0
    public void BlackListHighlightsDealWithMultipleOverlapsCorrectly()
    {
        var selection = new LabelSelectionViewModel(Money.Parse("1.0"));

        var pockets = new List <Pocket>();

        pockets.AddPocket(1.0M, out var pocket1, "Target", "Dan");
        pockets.AddPocket(1.0M, out var pocket2, "Target");
        pockets.AddPocket(1.0M, out var pocket3, "Target", "Roland");

        selection.Reset(pockets.ToArray());

        selection.SwapLabel(selection.GetLabel("Target"));

        Assert.Contains(selection.GetLabel("Target"), selection.LabelsBlackList);
        Assert.Contains(selection.GetLabel("Roland"), selection.LabelsBlackList);
        Assert.Contains(selection.GetLabel("Dan"), selection.LabelsBlackList);

        selection.GetLabel("Dan").IsPointerOver = true;

        Assert.True(selection.GetLabel("Dan").IsHighlighted);
        Assert.False(selection.GetLabel("Roland").IsHighlighted);
        Assert.True(selection.GetLabel("Target").IsHighlighted);

        var output = selection.GetUsedPockets();

        Assert.DoesNotContain(pocket1, output);
        Assert.DoesNotContain(pocket2, output);
        Assert.DoesNotContain(pocket3, output);
    }
示例#5
0
    public void NotEnoughSelectedWhenSameLabelFoundInSeveralPockets()
    {
        var selection = new LabelSelectionViewModel(Money.Parse("1.0"));

        var pockets = new List <Pocket>();

        pockets.AddPocket(0.4M, out _, "Dan");
        pockets.AddPocket(2.0M, out _, "Dan", "David");

        selection.Reset(pockets.ToArray());

        selection.SwapLabel(selection.GetLabel("Dan"));
        selection.SwapLabel(selection.GetLabel("Dan"));

        Assert.DoesNotContain(selection.GetLabel("Dan"), selection.LabelsBlackList);
        Assert.DoesNotContain(selection.GetLabel("David"), selection.LabelsWhiteList);

        Assert.False(selection.EnoughSelected);
    }
示例#6
0
    public void WhiteListSwapsAllLabelsInOtherPocketsThatContainTargetLabelAndTheOtherLabelsInThosePockets()
    {
        var selection = new LabelSelectionViewModel(Money.Parse("1.0"));

        var pockets = new List <Pocket>();

        pockets.AddPocket(1.0M, out _, "Target", "Dan", "Roland");
        pockets.AddPocket(1.0M, out _, "Dan");

        selection.Reset(pockets.ToArray());

        selection.SwapLabel(selection.GetLabel("Dan"));

        Assert.Contains(selection.GetLabel("Target"), selection.LabelsBlackList);
        Assert.Contains(selection.GetLabel("Roland"), selection.LabelsBlackList);
        Assert.Contains(selection.GetLabel("Dan"), selection.LabelsBlackList);
    }
示例#7
0
    public LabelViewModel(LabelSelectionViewModel owner, string label)
    {
        Value = label;

        this.WhenAnyValue(x => x.IsPointerOver)
        .Skip(1)
        .Where(value => value == true)
        .Subscribe(_ =>
        {
            owner.OnPointerOver(this);
            owner.OnFade(this);
        });

        ClickedCommand = ReactiveCommand.Create(() => owner.SwapLabel(this));

        _toolTip = label;
    }
示例#8
0
    public void OutPutMatchesWhiteListScenario1()
    {
        var selection = new LabelSelectionViewModel(Money.Parse("1.0"));

        var pockets = new List <Pocket>();

        pockets.AddPocket(1.0M, out var pocket1, "Target", "Dan", "Roland");
        pockets.AddPocket(1.0M, out var pocket2, "Dan");

        selection.Reset(pockets.ToArray());

        selection.SwapLabel(selection.GetLabel("Dan"));

        var output = selection.GetUsedPockets();

        Assert.DoesNotContain(pocket1, output);
        Assert.DoesNotContain(pocket2, output);
    }
示例#9
0
    public void UseOnlyPrivateFunds()
    {
        var selection = new LabelSelectionViewModel(Money.Parse("1.0"));

        var pockets = new List <Pocket>();

        pockets.AddPocket(1.0M, out var pocket1, CoinPocketHelper.PrivateFundsText);
        pockets.AddPocket(2.0M, out var pocket2, "Dan");

        selection.Reset(pockets.ToArray());

        selection.SwapLabel(selection.GetLabel("Dan"));

        Assert.Contains(selection.GetLabel("Dan"), selection.LabelsBlackList);
        Assert.True(selection.EnoughSelected);

        var output = selection.GetUsedPockets();

        Assert.DoesNotContain(pocket2, output);
        Assert.Contains(pocket1, output);
    }
示例#10
0
    public void WhiteListSwapsGroupedLabelsInOtherPocketsThatContainTargetLabelExceptThoseAvailableInOtherPockets()
    {
        var selection = new LabelSelectionViewModel(Money.Parse("1.0"));

        var pockets = new List <Pocket>();

        pockets.AddPocket(1.0M, out var pocket1, "Target", "Dan");
        pockets.AddPocket(1.0M, out var pocket2, "Target");
        pockets.AddPocket(1.0M, out var pocket3, "Target", "Roland");

        selection.Reset(pockets.ToArray());

        selection.SwapLabel(selection.GetLabel("Dan"));

        Assert.DoesNotContain(selection.GetLabel("Target"), selection.LabelsBlackList);
        Assert.DoesNotContain(selection.GetLabel("Roland"), selection.LabelsBlackList);
        Assert.Contains(selection.GetLabel("Dan"), selection.LabelsBlackList);

        var output = selection.GetUsedPockets();

        Assert.DoesNotContain(pocket1, output);
        Assert.Contains(pocket2, output);
        Assert.Contains(pocket3, output);
    }