1
exercism fetch csharp change

ChangeTest.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using Xunit;

public class ChangeTest
{
    [Fact]
    public void Single_coin_change()
    {
        var actual = new[] { 1, 5, 10, 25, 100 };
        var target = 25;
        var expected = new[] { 25 };
        Assert.Equal(expected, Change.Calculate(target, actual));
    }

    [Fact(Skip = "Remove to run test")]
    public void Multiple_coin_change()
    {
        var actual = new[] { 1, 5, 10, 25, 100 };
        var target = 15;
        var expected = new[] { 5, 10 };
        Assert.Equal(expected, Change.Calculate(target, actual));
    }

    [Fact(Skip = "Remove to run test")]
    public void Change_with_Lilliputian_Coins()
    {
        var actual = new[] { 1, 4, 15, 20, 50 };
        var target = 23;
        var expected = new[] { 4, 4, 15 };
        Assert.Equal(expected, Change.Calculate(target, actual));
    }

    [Fact(Skip = "Remove to run test")]
    public void Change_with_Lower_Elbonia_Coins()
    {
        var actual = new[] { 1, 5, 10, 21, 25 };
        var target = 63;
        var expected = new[] { 21, 21, 21 };
        Assert.Equal(expected, Change.Calculate(target, actual));
    }

    [Fact(Skip = "Remove to run test")]
    public void Large_target_values()
    {
        var actual = new[] { 1, 2, 5, 10, 20, 50, 100 };
        var target = 999;
        var expected = new[] { 2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100 };
        Assert.Equal(expected, Change.Calculate(target, actual));
    }

    [Fact(Skip = "Remove to run test")]
    public void No_coins_make_0_change()
    {
        var actual = new[] { 1, 5, 10, 21, 25 };
        var target = 0;
        var expected = new int[0];
        Assert.Equal(expected, Change.Calculate(target, actual));
    }

    [Fact(Skip = "Remove to run test")]
    public void Error_testing_for_change_smaller_than_the_smallest_of_coins()
    {
        var actual = new[] { 5, 10 };
        var target = 3;
        Assert.Throws<ArgumentException>(() => Change.Calculate(target, actual));
    }

    [Fact(Skip = "Remove to run test")]
    public void Cannot_find_negative_change_values()
    {
        var actual = new[] { 1, 2, 5 };
        var target = -5;
        Assert.Throws<ArgumentException>(() => Change.Calculate(target, actual));
    }
}