diff --git a/exercises/prime-factors/Example.cs b/exercises/prime-factors/Example.cs index 91d3df31a3..d52dd89383 100644 --- a/exercises/prime-factors/Example.cs +++ b/exercises/prime-factors/Example.cs @@ -2,9 +2,9 @@ public class PrimeFactors { - public static int[] Factors(long number) + public static long[] Factors(long number) { - var primes = new List(); + var primes = new List(); int divisor = 2; while (number > 1) { diff --git a/exercises/prime-factors/PrimeFactors.cs b/exercises/prime-factors/PrimeFactors.cs index fcb7016eb6..692a118d1e 100644 --- a/exercises/prime-factors/PrimeFactors.cs +++ b/exercises/prime-factors/PrimeFactors.cs @@ -2,7 +2,7 @@ public static class PrimeFactors { - public static int[] Factors(long number) + public static long[] Factors(long number) { throw new NotImplementedException(); } diff --git a/exercises/prime-factors/PrimeFactorsTest.cs b/exercises/prime-factors/PrimeFactorsTest.cs index 331329a789..a67e9c3c14 100644 --- a/exercises/prime-factors/PrimeFactorsTest.cs +++ b/exercises/prime-factors/PrimeFactorsTest.cs @@ -13,36 +13,36 @@ public void No_factors() [Fact(Skip = "Remove to run test")] public void Prime_number() { - Assert.Equal(new[] { 2 }, PrimeFactors.Factors(2L)); + Assert.Equal(new[] { 2L }, PrimeFactors.Factors(2L)); } [Fact(Skip = "Remove to run test")] public void Square_of_a_prime() { - Assert.Equal(new[] { 3, 3 }, PrimeFactors.Factors(9L)); + Assert.Equal(new[] { 3L, 3L }, PrimeFactors.Factors(9L)); } [Fact(Skip = "Remove to run test")] public void Cube_of_a_prime() { - Assert.Equal(new[] { 2, 2, 2 }, PrimeFactors.Factors(8L)); + Assert.Equal(new[] { 2L, 2L, 2L }, PrimeFactors.Factors(8L)); } [Fact(Skip = "Remove to run test")] public void Product_of_primes_and_non_primes() { - Assert.Equal(new[] { 2, 2, 3 }, PrimeFactors.Factors(12L)); + Assert.Equal(new[] { 2L, 2L, 3L }, PrimeFactors.Factors(12L)); } [Fact(Skip = "Remove to run test")] public void Product_of_primes() { - Assert.Equal(new[] { 5, 17, 23, 461 }, PrimeFactors.Factors(901255L)); + Assert.Equal(new[] { 5L, 17L, 23L, 461L }, PrimeFactors.Factors(901255L)); } [Fact(Skip = "Remove to run test")] public void Factors_include_a_large_prime() { - Assert.Equal(new[] { 11, 9539, 894119 }, PrimeFactors.Factors(93819012551L)); + Assert.Equal(new[] { 11L, 9539L, 894119L }, PrimeFactors.Factors(93819012551L)); } } \ No newline at end of file diff --git a/generators/Exercises/Generators/PrimeFactors.cs b/generators/Exercises/Generators/PrimeFactors.cs index 09c0dad850..e157bc923a 100644 --- a/generators/Exercises/Generators/PrimeFactors.cs +++ b/generators/Exercises/Generators/PrimeFactors.cs @@ -1,10 +1,18 @@ -using Exercism.CSharp.Output; +using System.Linq; +using Exercism.CSharp.Output; namespace Exercism.CSharp.Exercises.Generators { public class PrimeFactors : GeneratorExercise { - protected override void UpdateTestMethod(TestMethod testMethod) => + protected override void UpdateTestMethod(TestMethod testMethod) + { testMethod.Input["value"] = (long)testMethod.Input["value"]; + + if (testMethod.Expected is int[] expected) + { + testMethod.Expected = expected.Select(l => (long)l).ToArray(); + } + } } } \ No newline at end of file diff --git a/generators/Output/TestClassOutput.cs b/generators/Output/TestClassOutput.cs index d76cc94ef7..44b5fac2fe 100644 --- a/generators/Output/TestClassOutput.cs +++ b/generators/Output/TestClassOutput.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Collections.Immutable; using System.IO; using System.Linq; using Exercism.CSharp.Helpers;