-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
496 changed files
with
22,271 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0"/> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> | ||
<PackageReference Include="xunit" Version="2.6.4" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Day01\Day01.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Day01.Tests | ||
{ | ||
public class EdibleTests | ||
{ | ||
private static readonly DateOnly ExpirationDate = new(2023, 12, 1); | ||
private static readonly Guid Inspector = Guid.NewGuid(); | ||
private static readonly DateOnly NotFreshDate = ExpirationDate.AddDays(7); | ||
private static readonly DateOnly FreshDate = ExpirationDate.AddDays(-7); | ||
|
||
public static IEnumerable<object?[]> NotEdibleFood() | ||
{ | ||
return new List<object?[]> | ||
{ | ||
new object[] {true, Inspector, NotFreshDate}, | ||
new object[] {false, Inspector, FreshDate}, | ||
new object?[] {true, null, FreshDate}, | ||
new object?[] {false, null, NotFreshDate}, | ||
new object?[] {false, null, FreshDate} | ||
}; | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(NotEdibleFood))] | ||
public void Not_Edible_If_Not_Fresh(bool approvedForConsumption, Guid? inspectorId, DateOnly now) | ||
=> new Food(ExpirationDate, approvedForConsumption, inspectorId) | ||
.IsEdible(() => now) | ||
.Should() | ||
.BeFalse(); | ||
|
||
[Fact] | ||
public void EdibleFood() | ||
=> new Food(ExpirationDate, true, Inspector) | ||
.IsEdible(() => FreshDate) | ||
.Should() | ||
.BeTrue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Day01 | ||
{ | ||
public record Food( | ||
DateOnly ExpirationDate, | ||
bool ApprovedForConsumption, | ||
Guid? InspectorId) | ||
{ | ||
public bool IsEdible(Func<DateOnly> now) | ||
{ | ||
if (ExpirationDate.CompareTo(now()) > 0 && | ||
ApprovedForConsumption && | ||
InspectorId != null) | ||
return true; | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0"/> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> | ||
<PackageReference Include="xunit" Version="2.6.4" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Day02\Day02.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Day02.Tests | ||
{ | ||
public class FizzBuzzTests | ||
{ | ||
#region "Normal" numbers | ||
|
||
[Fact] | ||
public void Returns_The_Given_Number_For_1() => FizzBuzz.Convert(1).Should().Be("1"); | ||
|
||
[Fact] | ||
public void Returns_The_Given_Number_For_67() => FizzBuzz.Convert(67).Should().Be("67"); | ||
|
||
[Fact] | ||
public void Returns_The_Given_Number_For_82() => FizzBuzz.Convert(82).Should().Be("82"); | ||
|
||
#endregion | ||
|
||
#region Fizz | ||
|
||
[Fact] | ||
public void Returns_Fizz_For_3() => FizzBuzz.Convert(3).Should().Be("Fizz"); | ||
|
||
[Fact] | ||
public void Returns_Fizz_For_66() => FizzBuzz.Convert(66).Should().Be("Fizz"); | ||
|
||
[Fact] | ||
public void Returns_Fizz_For_99() => FizzBuzz.Convert(99).Should().Be("Fizz"); | ||
|
||
#endregion | ||
|
||
#region Buzz | ||
|
||
[Fact] | ||
public void Returns_Buzz_For_5() => FizzBuzz.Convert(5).Should().Be("Buzz"); | ||
|
||
[Fact] | ||
public void Returns_Buzz_For_50() => FizzBuzz.Convert(50).Should().Be("Buzz"); | ||
|
||
[Fact] | ||
public void Returns_Buzz_For_85() => FizzBuzz.Convert(85).Should().Be("Buzz"); | ||
|
||
#endregion | ||
|
||
#region FizzBuzz | ||
|
||
[Fact] | ||
public void Returns_FizzBuzz_For_15() => FizzBuzz.Convert(15).Should().Be("FizzBuzz"); | ||
|
||
[Fact] | ||
public void Returns_FizzBuzz_For_30() => FizzBuzz.Convert(30).Should().Be("FizzBuzz"); | ||
|
||
[Fact] | ||
public void Returns_FizzBuzz_For_45() => FizzBuzz.Convert(45).Should().Be("FizzBuzz"); | ||
|
||
#endregion | ||
|
||
#region Failures | ||
|
||
[Fact] | ||
public void Throws_An_Exception_For_0() | ||
{ | ||
var act = () => FizzBuzz.Convert(0); | ||
act.Should().Throw<OutOfRangeException>(); | ||
} | ||
|
||
[Fact] | ||
public void Throws_An_Exception_For_101() | ||
{ | ||
var act = () => FizzBuzz.Convert(101); | ||
act.Should().Throw<OutOfRangeException>(); | ||
} | ||
|
||
[Fact] | ||
public void Throws_An_Exception_For_Minus_1() | ||
{ | ||
var act = () => FizzBuzz.Convert(-1); | ||
act.Should().Throw<OutOfRangeException>(); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
namespace Day02 | ||
{ | ||
public static class FizzBuzz | ||
{ | ||
public static string Convert(int input) | ||
{ | ||
if (input > 0) | ||
{ | ||
if (input <= 100) | ||
{ | ||
if (input % 3 == 0 && input % 5 == 0) | ||
{ | ||
return "FizzBuzz"; | ||
} | ||
|
||
if (input % 3 == 0) | ||
{ | ||
return "Fizz"; | ||
} | ||
|
||
if (input % 5 == 0) | ||
{ | ||
return "Buzz"; | ||
} | ||
|
||
return input.ToString(); | ||
} | ||
else | ||
{ | ||
throw new OutOfRangeException(); | ||
} | ||
} | ||
else | ||
{ | ||
throw new OutOfRangeException(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Day02 | ||
{ | ||
public sealed class OutOfRangeException : ArgumentException | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0"/> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> | ||
<PackageReference Include="xunit" Version="2.6.4" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Day03\Day03\Day03.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
using static Day03.PetType; | ||
|
||
namespace Day03.Tests | ||
{ | ||
public class PopulationTests | ||
{ | ||
private static readonly IEnumerable<Person> Population = new List<Person> | ||
{ | ||
new("Peter", "Griffin", new Pet(Cat, "Tabby", 2)), | ||
new("Stewie", "Griffin", new Pet(Cat, "Dolly", 3), new Pet(Dog, "Brian", 9)), | ||
new("Joe", "Swanson", new Pet(Dog, "Spike", 4)), | ||
new("Lois", "Griffin", new Pet(Snake, "Serpy", 1)), | ||
new("Meg", "Griffin", new Pet(Bird, "Tweety", 1)), | ||
new("Chris", "Griffin", new Pet(Turtle, "Speedy", 4)), | ||
new("Cleveland", "Brown", new Pet(Hamster, "Fuzzy", 1), new Pet(Hamster, "Wuzzy", 2)), | ||
new("Glenn", "Quagmire") | ||
}; | ||
|
||
[Fact] | ||
public void Who_Owns_The_Youngest_Pet() | ||
{ | ||
var filtered = Population.MinBy(person => { var youngestPetByAge = person.Pets.MinBy(p => p.Age); return youngestPetByAge?.Age ?? int.MaxValue; }); | ||
|
||
filtered.Should().NotBeNull(); | ||
filtered!.FirstName.Should().Be("Lois"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Day03 | ||
{ | ||
public record Person(string FirstName, string LastName, params Pet[] Pets); | ||
|
||
public record Pet(PetType Type, string Name, int Age); | ||
|
||
public enum PetType | ||
{ | ||
Cat, | ||
Dog, | ||
Hamster, | ||
Turtle, | ||
Bird, | ||
Snake | ||
} | ||
} |
Oops, something went wrong.