Sha256: f3a59c8742a6617c103b00c520fd0ef33668748b7b34ad745e71f11d37d549f9

Contents?: true

Size: 1.53 KB

Versions: 115

Compression:

Stored size: 1.53 KB

Contents

using System.Linq;
using NUnit.Framework;

[TestFixture]
public class PythagoreanTripletTest
{
    [Test]
    public void Calculates_the_sum()
    {
        Assert.That(new Triplet(3, 4, 5).Sum(), Is.EqualTo(12));
    }

    [Ignore("Remove to run test")]
    [Test]
    public void Calculates_the_product()
    {
        Assert.That(new Triplet(3, 4, 5).Product(), Is.EqualTo(60));
    }

    [Ignore("Remove to run test")]
    [TestCase(3, 4, 5, ExpectedResult = true)]
    [TestCase(5, 6, 7, ExpectedResult = false)]
    public bool Can_recognize_a_valid_pythagorean(int a, int b, int c)
    {
        return new Triplet(a, b, c).IsPythagorean();
    }

    [Ignore("Remove to run test")]
    [Test]
    public void Can_make_triplets_up_to_10()
    {
        var triplets = Triplet.Where(maxFactor: 10);
        var products = triplets.Select(x => x.Product()).OrderBy(x => x);
        Assert.That(products, Is.EqualTo(new[] { 60, 480 }));
    }

    [Ignore("Remove to run test")]
    [Test]
    public void Can_make_triplets_from_11_to_20()
    {
        var triplets = Triplet.Where(minFactor: 11, maxFactor: 20);
        var products = triplets.Select(x => x.Product());
        Assert.That(products, Is.EqualTo(new[] { 3840 }));
    }

    [Ignore("Remove to run test")]
    [Test]
    public void Can_make_triplets_filtered_on_sum()
    {
        var triplets = Triplet.Where(sum: 180, maxFactor: 100);
        var products = triplets.Select(x => x.Product()).OrderBy(x => x);
        Assert.That(products, Is.EqualTo(new[] { 118080, 168480, 202500 }));
    }
}

Version data entries

115 entries across 115 versions & 1 rubygems

Version Path
trackler-2.0.8.14 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.13 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.12 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.11 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.10 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.9 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.8 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.7 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.6 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.5 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.4 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.3 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.2 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.8.1 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.7.0 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.6.44 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.6.43 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.6.42 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.6.41 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs
trackler-2.0.6.40 tracks/csharp/exercises/pythagorean-triplet/PythagoreanTripletTest.cs