public void CoinChangeProblemSimpleTest() { var coinChanger = new CoinChange(); var firstResult = coinChanger.DynamicCoinCange(6, new int[] { 1, 3, 4 }); var secondResult = coinChanger.DynamicCoinCange(12, new int[] { 1, 6, 8 }); var thirdResult = coinChanger.DynamicCoinCange(48, new int[] { 1, 16, 40 }); var fourthResult = coinChanger.DynamicCoinCange(50, new int[] { 5, 25, 40 }); var fifthResult = coinChanger.DynamicCoinCange(500, new int[] { 10, 250, 480 }); firstResult.Should().Be("2 * 3"); secondResult.Should().Be("2 * 6"); thirdResult.Should().Be("3 * 16"); fourthResult.Should().Be("2 * 25"); fifthResult.Should().Be("2 * 250"); }
public void InvalidInputSimpleTest() { var coinChanger = new CoinChange(); Action negativeInteger = () => coinChanger.DynamicCoinCange(-6, new int[] { 1, 3, 4 }); Action negativeCoin = () => coinChanger.DynamicCoinCange(12, new int[] { 1, -6, 8 }); Action notUniqueCoins = () => coinChanger.DynamicCoinCange(48, new int[] { 1, 16, 40, 40 }); var nullIntegerValueResult = coinChanger.DynamicCoinCange(0, new int[] { 5, 25, 40 }); negativeCoin.Should().Throw <Exception>() .WithMessage("Coin should be positive integer"); negativeInteger.Should().Throw <Exception>() .WithMessage("Input should be a positive integer"); notUniqueCoins.Should().Throw <Exception>() .WithMessage("Coins should have unique values"); nullIntegerValueResult.Should().Be(string.Empty); }