Skip to content

Commit 49a7611

Browse files
committed
Updated to net 7 and re-structured the solution
1 parent c9aced8 commit 49a7611

25 files changed

+435
-285
lines changed

Problem1/Lib.cs

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.ComponentModel;
43
using System.Linq;
5-
using System.Runtime.CompilerServices;
64

7-
namespace Problem1
8-
{
9-
public static class Lib
10-
{
11-
public static IEnumerable<int> ReturnMultiplesOf3And5(int range)
12-
{
5+
namespace Problem1 {
6+
public static class Lib {
7+
public static IEnumerable<int> ReturnMultiplesOf3And5(int range) {
138
if (range < 3)
149
throw new ArgumentOutOfRangeException(nameof(range));
1510

1611
return Enumerable
17-
.Range(3, range-3)
18-
.Where(x => (x % 3 == 0 || x % 5 == 0));
12+
.Range(3, range - 3)
13+
.Where(x => x % 3 == 0 || x % 5 == 0);
1914
}
2015

21-
public static int ReturnSumOfMultiplesOf3And5(int range) =>
22-
ReturnMultiplesOf3And5(range).Sum();
23-
16+
public static int ReturnSumOfMultiplesOf3And5(int range) {
17+
return ReturnMultiplesOf3And5(range).Sum();
18+
}
2419
}
2520
}

Problem1/Problem1.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<TargetFramework>net7.0</TargetFramework>
66
</PropertyGroup>
77

88
</Project>

Problem2/Problem2.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<TargetFramework>net7.0</TargetFramework>
66
</PropertyGroup>
77

88
</Project>

Problem3/Problem3.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<TargetFramework>net7.0</TargetFramework>
66
</PropertyGroup>
77

88
</Project>

Problem4/Problem4.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<TargetFramework>net7.0</TargetFramework>
66
</PropertyGroup>
77

88
</Project>

Problem5/Problem5.csproj

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<TargetFramework>net7.0</TargetFramework>
66
</PropertyGroup>
77

8-
<ItemGroup>
9-
<ProjectReference Include="..\Problem3\Problem3.csproj" />
10-
</ItemGroup>
11-
128
</Project>

Problem6/Problem6.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<TargetFramework>net7.0</TargetFramework>
66
</PropertyGroup>
77

88
</Project>

Problem7/Problem7.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<TargetFramework>net7.0</TargetFramework>
66
</PropertyGroup>
77

88
</Project>

ProjectEuler.sln

+8-44
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.28407.52
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.4.33103.184
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectEuler", "ProjectEuler\ProjectEuler.csproj", "{1857A7BA-997A-4E35-8EB9-7FED8ECC04D3}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectEulerProblems.Tests", "ProjectEuler\ProjectEulerProblems.Tests.csproj", "{1857A7BA-997A-4E35-8EB9-7FED8ECC04D3}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Problem1", "Problem1\Problem1.csproj", "{E17A9169-6CDB-40A1-8308-FF80051B39FF}"
9-
EndProject
10-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Problem2", "Problem2\Problem2.csproj", "{197C874E-A154-4CC1-AEBD-BA4E7DB34EFD}"
11-
EndProject
12-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Problem3", "Problem3\Problem3.csproj", "{A3C42278-FE60-4822-BFE6-B568D73ED25C}"
13-
EndProject
14-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Problem4", "Problem4\Problem4.csproj", "{ECDD1EAA-A0B6-4429-8DA5-BEBFA27E585C}"
15-
EndProject
16-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Problem5", "Problem5\Problem5.csproj", "{4FB856A4-8068-4B52-BF5E-9573993CFAB6}"
17-
EndProject
18-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Problem6", "Problem6\Problem6.csproj", "{DF652B11-4EA6-45B1-B6BA-B0AB3FB96122}"
19-
EndProject
20-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Problem7", "Problem7\Problem7.csproj", "{67ED332A-C6F8-4FA0-8EDB-5D2E3D6F1E31}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectEulerProblems", "ProjectEulerProblems\ProjectEulerProblems.csproj", "{7DDD0249-7855-434E-9CBD-05BC98ACEA42}"
219
EndProject
2210
Global
2311
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -29,34 +17,10 @@ Global
2917
{1857A7BA-997A-4E35-8EB9-7FED8ECC04D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
3018
{1857A7BA-997A-4E35-8EB9-7FED8ECC04D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
3119
{1857A7BA-997A-4E35-8EB9-7FED8ECC04D3}.Release|Any CPU.Build.0 = Release|Any CPU
32-
{E17A9169-6CDB-40A1-8308-FF80051B39FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33-
{E17A9169-6CDB-40A1-8308-FF80051B39FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
34-
{E17A9169-6CDB-40A1-8308-FF80051B39FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
35-
{E17A9169-6CDB-40A1-8308-FF80051B39FF}.Release|Any CPU.Build.0 = Release|Any CPU
36-
{197C874E-A154-4CC1-AEBD-BA4E7DB34EFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37-
{197C874E-A154-4CC1-AEBD-BA4E7DB34EFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
38-
{197C874E-A154-4CC1-AEBD-BA4E7DB34EFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
39-
{197C874E-A154-4CC1-AEBD-BA4E7DB34EFD}.Release|Any CPU.Build.0 = Release|Any CPU
40-
{A3C42278-FE60-4822-BFE6-B568D73ED25C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41-
{A3C42278-FE60-4822-BFE6-B568D73ED25C}.Debug|Any CPU.Build.0 = Debug|Any CPU
42-
{A3C42278-FE60-4822-BFE6-B568D73ED25C}.Release|Any CPU.ActiveCfg = Release|Any CPU
43-
{A3C42278-FE60-4822-BFE6-B568D73ED25C}.Release|Any CPU.Build.0 = Release|Any CPU
44-
{ECDD1EAA-A0B6-4429-8DA5-BEBFA27E585C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45-
{ECDD1EAA-A0B6-4429-8DA5-BEBFA27E585C}.Debug|Any CPU.Build.0 = Debug|Any CPU
46-
{ECDD1EAA-A0B6-4429-8DA5-BEBFA27E585C}.Release|Any CPU.ActiveCfg = Release|Any CPU
47-
{ECDD1EAA-A0B6-4429-8DA5-BEBFA27E585C}.Release|Any CPU.Build.0 = Release|Any CPU
48-
{4FB856A4-8068-4B52-BF5E-9573993CFAB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49-
{4FB856A4-8068-4B52-BF5E-9573993CFAB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
50-
{4FB856A4-8068-4B52-BF5E-9573993CFAB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
51-
{4FB856A4-8068-4B52-BF5E-9573993CFAB6}.Release|Any CPU.Build.0 = Release|Any CPU
52-
{DF652B11-4EA6-45B1-B6BA-B0AB3FB96122}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53-
{DF652B11-4EA6-45B1-B6BA-B0AB3FB96122}.Debug|Any CPU.Build.0 = Debug|Any CPU
54-
{DF652B11-4EA6-45B1-B6BA-B0AB3FB96122}.Release|Any CPU.ActiveCfg = Release|Any CPU
55-
{DF652B11-4EA6-45B1-B6BA-B0AB3FB96122}.Release|Any CPU.Build.0 = Release|Any CPU
56-
{67ED332A-C6F8-4FA0-8EDB-5D2E3D6F1E31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57-
{67ED332A-C6F8-4FA0-8EDB-5D2E3D6F1E31}.Debug|Any CPU.Build.0 = Debug|Any CPU
58-
{67ED332A-C6F8-4FA0-8EDB-5D2E3D6F1E31}.Release|Any CPU.ActiveCfg = Release|Any CPU
59-
{67ED332A-C6F8-4FA0-8EDB-5D2E3D6F1E31}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{7DDD0249-7855-434E-9CBD-05BC98ACEA42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{7DDD0249-7855-434E-9CBD-05BC98ACEA42}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{7DDD0249-7855-434E-9CBD-05BC98ACEA42}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{7DDD0249-7855-434E-9CBD-05BC98ACEA42}.Release|Any CPU.Build.0 = Release|Any CPU
6024
EndGlobalSection
6125
GlobalSection(SolutionProperties) = preSolution
6226
HideSolutionNode = FALSE

ProjectEuler/ProjectEuler.csproj

-42
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
9+
<PackageReference Include="xunit" Version="2.4.2" />
10+
<PackageReference Include="xunit.analyzers" Version="1.0.0" />
11+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
12+
<PrivateAssets>all</PrivateAssets>
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
14+
</PackageReference>
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\ProjectEulerProblems\ProjectEulerProblems.csproj" />
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<Reference Include="xunit.abstractions">
23+
<HintPath>xunit.abstractions</HintPath>
24+
</Reference>
25+
<Reference Include="xunit.assert">
26+
<HintPath>xunit.assert</HintPath>
27+
</Reference>
28+
<Reference Include="xunit.core">
29+
<HintPath>xunit.core</HintPath>
30+
</Reference>
31+
</ItemGroup>
32+
33+
</Project>

ProjectEuler/Tests/Problem1Tests.cs

+22-26
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
11
// Autogenerated by Paul for the purpose of testing the Problem1 class
22

33
using System;
4-
using System.Collections.Generic;
5-
using System.IO;
6-
using System.Text;
4+
using ProjectEulerProblems.Problem_1;
75
using Xunit;
8-
using Problem1;
96

10-
namespace ProjectEuler.Tests
7+
namespace ProjectEulerProblems.Tests.Tests;
8+
9+
/// <summary>
10+
/// %%%%% Autogenerated class documentation from the IGT templates engine %%%%%
11+
/// This class tests the operational functionality of the original source class
12+
/// <see cref="ProjectEuler.Tests.Problem1"/>.
13+
/// </summary>
14+
public class Problem1Tests
1115
{
12-
/// <summary>
13-
/// %%%%% Autogenerated class documentation from the IGT templates engine %%%%%
14-
/// This class tests the operational functionality of the original source class
15-
/// <see cref="ProjectEuler.Tests.Problem1"/>.
16-
/// </summary>
17-
public class Problem1Tests
16+
[Fact]
17+
public void Lib_ShouldThrowException_WithOutOfRangeParam()
1818
{
19-
[Fact]
20-
public void Lib_ShouldThrowException_WithOutOfRangeParam()
21-
{
22-
Assert.Throws<ArgumentOutOfRangeException>(() => Lib.ReturnMultiplesOf3And5(0));
23-
}
19+
Assert.Throws<ArgumentOutOfRangeException>(() => Lib.ReturnMultiplesOf3And5(0));
20+
}
2421

25-
[Theory]
26-
[InlineData(10, 23)]
27-
[InlineData(1000, 233168)]
28-
public void Lib_ShouldPass_WithRange_AndAnswer(int input, int expected) =>
29-
Assert.Equal(expected, Lib.ReturnSumOfMultiplesOf3And5(input));
22+
[Theory]
23+
[InlineData(10, 23)]
24+
[InlineData(1000, 233168)]
25+
public void Lib_ShouldPass_WithRange_AndAnswer(int input, int expected) =>
26+
Assert.Equal(expected, Lib.ReturnSumOfMultiplesOf3And5(input));
3027

31-
[Fact]
32-
public void Lib_ShouldThrow_ErrorWithInvalidInput() =>
33-
Assert.Throws<ArgumentOutOfRangeException>(() => Problem1.Lib.ReturnSumOfMultiplesOf3And5(0));
34-
}
35-
}
28+
[Fact]
29+
public void Lib_ShouldThrow_ErrorWithInvalidInput() =>
30+
Assert.Throws<ArgumentOutOfRangeException>(() => Lib.ReturnSumOfMultiplesOf3And5(0));
31+
}

ProjectEuler/Tests/Problem2Tests.cs

+29-34
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
1-
using System;
2-
using System.Collections;
3-
using System.Collections.Generic;
1+
using System.Collections.Generic;
42
using System.Linq;
5-
using System.Text;
6-
using Problem2;
3+
using ProjectEulerProblems.Problem_2;
74
using Xunit;
85

9-
namespace ProjectEuler.Tests
10-
{
11-
/// <summary>
12-
/// %%%%% Autogenerated class documentation from the IGT templates engine %%%%%
13-
/// This class tests the operational functionality of the original source class
14-
/// <see cref="ProjectEuler.Tests.Problem2Tests"/>.
15-
/// </summary>
16-
public class Problem2Tests
6+
namespace ProjectEulerProblems.Tests.Tests;
7+
8+
/// <summary>
9+
/// %%%%% Autogenerated class documentation from the IGT templates engine %%%%%
10+
/// This class tests the operational functionality of the original source class
11+
/// <see cref="Problem2Tests" />.
12+
/// </summary>
13+
public class Problem2Tests {
14+
[Fact]
15+
public void checkGeneratedsequence()
1716
{
18-
[Fact]
19-
public void checkGeneratedsequence()
20-
{
21-
IEnumerable<int> expected = GenerateFake_fib();
22-
IEnumerable<int> actual = Lib.GenerateSequence(90);
17+
IEnumerable<int> expected = GenerateFake_fib();
18+
IEnumerable<int> actual = Lib.GenerateSequence(90);
2319

24-
Assert.Equal(expected.Count(), actual.Count());
25-
Assert.Equal(expected.Sum(), actual.Sum());
26-
}
20+
Assert.Equal(expected.Count(), actual.Count());
21+
Assert.Equal(expected.Sum(), actual.Sum());
22+
}
2723

28-
public static IEnumerable<int> GenerateFake_fib()
24+
public static IEnumerable<int> GenerateFake_fib()
25+
{
26+
return new List<int>
2927
{
30-
return new List<int>
31-
{
32-
1, 2, 3, 5, 8, 13, 21, 34, 55, 89
33-
};
34-
}
28+
1, 2, 3, 5, 8, 13, 21, 34, 55, 89
29+
};
30+
}
3531

36-
[Fact]
37-
public void checkevensumwithgeneratedsequance()
38-
{
39-
IEnumerable<int> actual = Lib.GenerateSequence(90);
32+
[Fact]
33+
public void checkevensumwithgeneratedsequance()
34+
{
35+
IEnumerable<int> actual = Lib.GenerateSequence(90);
4036

41-
Assert.Equal(44, Lib.SumOfEvenValues(actual));
42-
}
37+
Assert.Equal(44, Lib.SumOfEvenValues(actual));
4338
}
44-
}
39+
}

0 commit comments

Comments
 (0)