|
| 1 | +Imports System |
| 2 | +Imports Xunit |
| 3 | + |
| 4 | +Public Class ChangeTests |
| 5 | + <Fact> |
| 6 | + Public Sub Change_for_1_cent() |
| 7 | + Dim coins = {1, 5, 10, 25} |
| 8 | + Dim target = 1 |
| 9 | + Dim expected = {1} |
| 10 | + Assert.Equal(expected, FindFewestCoins(coins, target)) |
| 11 | + End Sub |
| 12 | + |
| 13 | + <Fact(Skip:="Remove this Skip property to run this test")> |
| 14 | + Public Sub Single_coin_change() |
| 15 | + Dim coins = {1, 5, 10, 25, 100} |
| 16 | + Dim target = 25 |
| 17 | + Dim expected = {25} |
| 18 | + Assert.Equal(expected, FindFewestCoins(coins, target)) |
| 19 | + End Sub |
| 20 | + |
| 21 | + <Fact(Skip:="Remove this Skip property to run this test")> |
| 22 | + Public Sub Multiple_coin_change() |
| 23 | + Dim coins = {1, 5, 10, 25, 100} |
| 24 | + Dim target = 15 |
| 25 | + Dim expected = {5, 10} |
| 26 | + Assert.Equal(expected, FindFewestCoins(coins, target)) |
| 27 | + End Sub |
| 28 | + |
| 29 | + <Fact(Skip:="Remove this Skip property to run this test")> |
| 30 | + Public Sub Change_with_lilliputian_coins() |
| 31 | + Dim coins = {1, 4, 15, 20, 50} |
| 32 | + Dim target = 23 |
| 33 | + Dim expected = {4, 4, 15} |
| 34 | + Assert.Equal(expected, FindFewestCoins(coins, target)) |
| 35 | + End Sub |
| 36 | + |
| 37 | + <Fact(Skip:="Remove this Skip property to run this test")> |
| 38 | + Public Sub Change_with_lower_elbonia_coins() |
| 39 | + Dim coins = {1, 5, 10, 21, 25} |
| 40 | + Dim target = 63 |
| 41 | + Dim expected = {21, 21, 21} |
| 42 | + Assert.Equal(expected, FindFewestCoins(coins, target)) |
| 43 | + End Sub |
| 44 | + |
| 45 | + <Fact(Skip:="Remove this Skip property to run this test")> |
| 46 | + Public Sub Large_target_values() |
| 47 | + Dim coins = {1, 2, 5, 10, 20, 50, 100} |
| 48 | + Dim target = 999 |
| 49 | + Dim expected = {2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100} |
| 50 | + Assert.Equal(expected, FindFewestCoins(coins, target)) |
| 51 | + End Sub |
| 52 | + |
| 53 | + <Fact(Skip:="Remove this Skip property to run this test")> |
| 54 | + Public Sub Possible_change_without_unit_coins_available() |
| 55 | + Dim coins = {2, 5, 10, 20, 50} |
| 56 | + Dim target = 21 |
| 57 | + Dim expected = {2, 2, 2, 5, 10} |
| 58 | + Assert.Equal(expected, FindFewestCoins(coins, target)) |
| 59 | + End Sub |
| 60 | + |
| 61 | + <Fact(Skip:="Remove this Skip property to run this test")> |
| 62 | + Public Sub Another_possible_change_without_unit_coins_available() |
| 63 | + Dim coins = {4, 5} |
| 64 | + Dim target = 27 |
| 65 | + Dim expected = {4, 4, 4, 5, 5, 5} |
| 66 | + Assert.Equal(expected, FindFewestCoins(coins, target)) |
| 67 | + End Sub |
| 68 | + |
| 69 | + <Fact(Skip:="Remove this Skip property to run this test")> |
| 70 | + Public Sub No_coins_make_0_change() |
| 71 | + Dim coins = {1, 5, 10, 21, 25} |
| 72 | + Dim target = 0 |
| 73 | + Assert.Empty(FindFewestCoins(coins, target)) |
| 74 | + End Sub |
| 75 | + |
| 76 | + <Fact(Skip:="Remove this Skip property to run this test")> |
| 77 | + Public Sub Error_testing_for_change_smaller_than_the_smallest_of_coins() |
| 78 | + Dim coins = {5, 10} |
| 79 | + Dim target = 3 |
| 80 | + Assert.Throws(Of ArgumentException)(Function() FindFewestCoins(coins, target)) |
| 81 | + End Sub |
| 82 | + |
| 83 | + <Fact(Skip:="Remove this Skip property to run this test")> |
| 84 | + Public Sub Error_if_no_combination_can_add_up_to_target() |
| 85 | + Dim coins = {5, 10} |
| 86 | + Dim target = 94 |
| 87 | + Assert.Throws(Of ArgumentException)(Function() FindFewestCoins(coins, target)) |
| 88 | + End Sub |
| 89 | + |
| 90 | + <Fact(Skip:="Remove this Skip property to run this test")> |
| 91 | + Public Sub Cannot_find_negative_change_values() |
| 92 | + Dim coins = {1, 2, 5} |
| 93 | + Dim target = -5 |
| 94 | + Assert.Throws(Of ArgumentException)(Function() FindFewestCoins(coins, target)) |
| 95 | + End Sub |
| 96 | +End Class |
0 commit comments