Sha256: 64a10e8615527fbbbca3a15840fb899414786cb033058abcef92092ffa06d8fc

Contents?: true

Size: 1.65 KB

Versions: 64

Compression:

Stored size: 1.65 KB

Contents

using NUnit.Framework;

[TestFixture]
public class LuhnTest
{
    [Test]
    public void Check_digit_is_the_rightmost_digit()
    {
        Assert.That(new Luhn(34567).CheckDigit, Is.EqualTo(7));
    }

    [Ignore("Remove to run test")]
    [Test]
    public void Addends_doubles_every_other_number_from_the_right()
    {
        Assert.That(new Luhn(12121).Addends, Is.EqualTo(new[] { 1, 4, 1, 4, 1 }));
    }

    [Ignore("Remove to run test")]
    [Test]
    public void Addends_subtracts_9_when_doubled_number_is_more_than_9()
    {
        Assert.That(new Luhn(8631).Addends, Is.EqualTo(new[] { 7, 6, 6, 1 }));
    }

    [Ignore("Remove to run test")]
    [TestCase(4913, ExpectedResult = 22)]
    [TestCase(201773, ExpectedResult = 21)]
    public int Checksum_adds_addends_together(int number)
    {
        return new Luhn(number).Checksum;
    }

    [Ignore("Remove to run test")]
    [TestCase(738, ExpectedResult = false)]
    [TestCase(8739567, ExpectedResult = true)]
    public bool Number_is_valid_when_checksum_mod_10_is_zero(int number)
    {
        return new Luhn(number).Valid;
    }

    [Ignore("Remove to run test")]
    [Test]
    public void Luhn_can_create_simple_numbers_with_valid_check_digit()
    {
        Assert.That(Luhn.Create(123), Is.EqualTo(1230));
    }

    [Ignore("Remove to run test")]
    [Test]
    public void Luhn_can_create_larger_numbers_with_valid_check_digit()
    {
        Assert.That(Luhn.Create(873956), Is.EqualTo(8739567));
    }

    [Ignore("Remove to run test")]
    [Test]
    public void Luhn_can_create_huge_numbers_with_valid_check_digit()
    {
        Assert.That(Luhn.Create(837263756), Is.EqualTo(8372637564));
    }
}

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
trackler-2.0.6.8 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.6.7 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.6.6 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.6.5 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.6.4 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.6.3 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.6.2 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.6.1 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.6.0 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.5.18 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.5.17 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.5.16 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.5.15 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.5.14 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.5.13 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.5.12 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.5.11 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.5.10 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.5.9 tracks/csharp/exercises/luhn/LuhnTest.cs
trackler-2.0.5.8 tracks/csharp/exercises/luhn/LuhnTest.cs