-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests and have language colors be dynamic
- Loading branch information
1 parent
ecf2500
commit 5c92396
Showing
9 changed files
with
112 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
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
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 @@ | ||
global using NUnit.Framework; |
39 changes: 39 additions & 0 deletions
39
tests/PersonalWebsite.Tests/Models/ProgrammingLanguageTests.cs
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 @@ | ||
using PersonalWebsite.Models; | ||
|
||
namespace PersonalWebsite.Tests.Models; | ||
|
||
public class ProgrammingLanguageTests | ||
{ | ||
[TestCase(ProgrammingLanguage.CSharp, "C#")] | ||
[TestCase(ProgrammingLanguage.CPlusPlus, "C++")] | ||
[TestCase(ProgrammingLanguage.Rust, "Rust")] | ||
[TestCase(ProgrammingLanguage.Python, "Python")] | ||
[TestCase((ProgrammingLanguage)10, "")] | ||
public void GetFormattedString_VariousInputs_ExpectedResponse(ProgrammingLanguage language, string expectedString) | ||
{ | ||
var response = language.GetFormattedString(); | ||
Assert.That(response, Is.EqualTo(expectedString)); | ||
} | ||
|
||
[TestCase(ProgrammingLanguage.CSharp, "text-purple-500")] | ||
[TestCase(ProgrammingLanguage.CPlusPlus, "text-sky-500")] | ||
[TestCase(ProgrammingLanguage.Rust, "text-red-500")] | ||
[TestCase(ProgrammingLanguage.Python, "text-blue-500")] | ||
[TestCase((ProgrammingLanguage)10, "text-green-500")] | ||
public void GetColor_StartNotProvided_TextReturned(ProgrammingLanguage language, string expectedColorClass) | ||
{ | ||
var color = language.GetColor(); | ||
Assert.That(color, Is.EqualTo(expectedColorClass)); | ||
} | ||
|
||
[TestCase(ProgrammingLanguage.CSharp, "bg-purple-500")] | ||
[TestCase(ProgrammingLanguage.CPlusPlus, "bg-sky-500")] | ||
[TestCase(ProgrammingLanguage.Rust, "bg-red-500")] | ||
[TestCase(ProgrammingLanguage.Python, "bg-blue-500")] | ||
[TestCase((ProgrammingLanguage)10, "bg-green-500")] | ||
public void GetColor_StartProvided_TextReturned(ProgrammingLanguage language, string expectedColorClass) | ||
{ | ||
var color = language.GetColor("bg"); | ||
Assert.That(color, Is.EqualTo(expectedColorClass)); | ||
} | ||
} |
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,24 @@ | ||
<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="Microsoft.NET.Test.Sdk" Version="17.6.0"/> | ||
<PackageReference Include="NUnit" Version="3.13.3"/> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1"/> | ||
<PackageReference Include="NUnit.Analyzers" Version="3.6.1"/> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\PersonalWebsite.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
26 changes: 26 additions & 0 deletions
26
tests/PersonalWebsite.Tests/Utilities/DateOnlyExtensionTests.cs
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,26 @@ | ||
using PersonalWebsite.Utilities; | ||
|
||
namespace PersonalWebsite.Tests.Utilities; | ||
|
||
public class DateOnlyExtensionTests | ||
{ | ||
[Test] | ||
public void GetDateString_EndDateProvided_DateRangeStringReturned() | ||
{ | ||
DateOnly | ||
startDate = new(2000, 1, 1), | ||
endDate = new(2001, 12, 31); | ||
var response = DateOnlyExtensions.GetDateString(startDate, endDate); | ||
|
||
Assert.That(response, Is.EqualTo("(2000-01-01 - 2001-12-31)")); | ||
} | ||
|
||
[Test] | ||
public void GetDateString_EndDateNotProvided_PresentStringReturned() | ||
{ | ||
var startDate = new DateOnly(2000, 1, 1); | ||
var response = DateOnlyExtensions.GetDateString(startDate, null); | ||
|
||
Assert.That(response, Is.EqualTo("(2000-01-01 - Present)")); | ||
} | ||
} |