Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions Hasheous.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,90 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "hasheous-lib", "hasheous-li
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "service-host", "service-host\service-host.csproj", "{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "hasheous-lib.Tests", "hasheous-lib.Tests\hasheous-lib.Tests.csproj", "{48D0391E-5FB8-4508-A850-C96A814864CF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{37509913-50FD-4865-888A-F5ABBE6C5D05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{37509913-50FD-4865-888A-F5ABBE6C5D05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{37509913-50FD-4865-888A-F5ABBE6C5D05}.Debug|x64.ActiveCfg = Debug|Any CPU
{37509913-50FD-4865-888A-F5ABBE6C5D05}.Debug|x64.Build.0 = Debug|Any CPU
{37509913-50FD-4865-888A-F5ABBE6C5D05}.Debug|x86.ActiveCfg = Debug|Any CPU
{37509913-50FD-4865-888A-F5ABBE6C5D05}.Debug|x86.Build.0 = Debug|Any CPU
{37509913-50FD-4865-888A-F5ABBE6C5D05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{37509913-50FD-4865-888A-F5ABBE6C5D05}.Release|Any CPU.Build.0 = Release|Any CPU
{37509913-50FD-4865-888A-F5ABBE6C5D05}.Release|x64.ActiveCfg = Release|Any CPU
{37509913-50FD-4865-888A-F5ABBE6C5D05}.Release|x64.Build.0 = Release|Any CPU
{37509913-50FD-4865-888A-F5ABBE6C5D05}.Release|x86.ActiveCfg = Release|Any CPU
{37509913-50FD-4865-888A-F5ABBE6C5D05}.Release|x86.Build.0 = Release|Any CPU
{D708CF76-505B-4954-911F-A535F5E18047}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D708CF76-505B-4954-911F-A535F5E18047}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D708CF76-505B-4954-911F-A535F5E18047}.Debug|x64.ActiveCfg = Debug|Any CPU
{D708CF76-505B-4954-911F-A535F5E18047}.Debug|x64.Build.0 = Debug|Any CPU
{D708CF76-505B-4954-911F-A535F5E18047}.Debug|x86.ActiveCfg = Debug|Any CPU
{D708CF76-505B-4954-911F-A535F5E18047}.Debug|x86.Build.0 = Debug|Any CPU
{D708CF76-505B-4954-911F-A535F5E18047}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D708CF76-505B-4954-911F-A535F5E18047}.Release|Any CPU.Build.0 = Release|Any CPU
{D708CF76-505B-4954-911F-A535F5E18047}.Release|x64.ActiveCfg = Release|Any CPU
{D708CF76-505B-4954-911F-A535F5E18047}.Release|x64.Build.0 = Release|Any CPU
{D708CF76-505B-4954-911F-A535F5E18047}.Release|x86.ActiveCfg = Release|Any CPU
{D708CF76-505B-4954-911F-A535F5E18047}.Release|x86.Build.0 = Release|Any CPU
{E925C33C-E514-4351-B709-13FFBF3F6CC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E925C33C-E514-4351-B709-13FFBF3F6CC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E925C33C-E514-4351-B709-13FFBF3F6CC9}.Debug|x64.ActiveCfg = Debug|Any CPU
{E925C33C-E514-4351-B709-13FFBF3F6CC9}.Debug|x64.Build.0 = Debug|Any CPU
{E925C33C-E514-4351-B709-13FFBF3F6CC9}.Debug|x86.ActiveCfg = Debug|Any CPU
{E925C33C-E514-4351-B709-13FFBF3F6CC9}.Debug|x86.Build.0 = Debug|Any CPU
{E925C33C-E514-4351-B709-13FFBF3F6CC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E925C33C-E514-4351-B709-13FFBF3F6CC9}.Release|Any CPU.Build.0 = Release|Any CPU
{E925C33C-E514-4351-B709-13FFBF3F6CC9}.Release|x64.ActiveCfg = Release|Any CPU
{E925C33C-E514-4351-B709-13FFBF3F6CC9}.Release|x64.Build.0 = Release|Any CPU
{E925C33C-E514-4351-B709-13FFBF3F6CC9}.Release|x86.ActiveCfg = Release|Any CPU
{E925C33C-E514-4351-B709-13FFBF3F6CC9}.Release|x86.Build.0 = Release|Any CPU
{DCDE72D0-5B03-4B5C-B85C-DCFEA3A93119}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DCDE72D0-5B03-4B5C-B85C-DCFEA3A93119}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DCDE72D0-5B03-4B5C-B85C-DCFEA3A93119}.Debug|x64.ActiveCfg = Debug|Any CPU
{DCDE72D0-5B03-4B5C-B85C-DCFEA3A93119}.Debug|x64.Build.0 = Debug|Any CPU
{DCDE72D0-5B03-4B5C-B85C-DCFEA3A93119}.Debug|x86.ActiveCfg = Debug|Any CPU
{DCDE72D0-5B03-4B5C-B85C-DCFEA3A93119}.Debug|x86.Build.0 = Debug|Any CPU
{DCDE72D0-5B03-4B5C-B85C-DCFEA3A93119}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DCDE72D0-5B03-4B5C-B85C-DCFEA3A93119}.Release|Any CPU.Build.0 = Release|Any CPU
{DCDE72D0-5B03-4B5C-B85C-DCFEA3A93119}.Release|x64.ActiveCfg = Release|Any CPU
{DCDE72D0-5B03-4B5C-B85C-DCFEA3A93119}.Release|x64.Build.0 = Release|Any CPU
{DCDE72D0-5B03-4B5C-B85C-DCFEA3A93119}.Release|x86.ActiveCfg = Release|Any CPU
{DCDE72D0-5B03-4B5C-B85C-DCFEA3A93119}.Release|x86.Build.0 = Release|Any CPU
{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}.Debug|x64.ActiveCfg = Debug|Any CPU
{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}.Debug|x64.Build.0 = Debug|Any CPU
{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}.Debug|x86.ActiveCfg = Debug|Any CPU
{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}.Debug|x86.Build.0 = Debug|Any CPU
{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}.Release|Any CPU.Build.0 = Release|Any CPU
{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}.Release|x64.ActiveCfg = Release|Any CPU
{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}.Release|x64.Build.0 = Release|Any CPU
{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}.Release|x86.ActiveCfg = Release|Any CPU
{EE31901D-72C9-48DF-B6A6-FDDBABE1F01C}.Release|x86.Build.0 = Release|Any CPU
{48D0391E-5FB8-4508-A850-C96A814864CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48D0391E-5FB8-4508-A850-C96A814864CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48D0391E-5FB8-4508-A850-C96A814864CF}.Debug|x64.ActiveCfg = Debug|Any CPU
{48D0391E-5FB8-4508-A850-C96A814864CF}.Debug|x64.Build.0 = Debug|Any CPU
{48D0391E-5FB8-4508-A850-C96A814864CF}.Debug|x86.ActiveCfg = Debug|Any CPU
{48D0391E-5FB8-4508-A850-C96A814864CF}.Debug|x86.Build.0 = Debug|Any CPU
{48D0391E-5FB8-4508-A850-C96A814864CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48D0391E-5FB8-4508-A850-C96A814864CF}.Release|Any CPU.Build.0 = Release|Any CPU
{48D0391E-5FB8-4508-A850-C96A814864CF}.Release|x64.ActiveCfg = Release|Any CPU
{48D0391E-5FB8-4508-A850-C96A814864CF}.Release|x64.Build.0 = Release|Any CPU
{48D0391E-5FB8-4508-A850-C96A814864CF}.Release|x86.ActiveCfg = Release|Any CPU
{48D0391E-5FB8-4508-A850-C96A814864CF}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
116 changes: 116 additions & 0 deletions hasheous-lib.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
using hasheous_server.Classes;

namespace hasheous_lib.Tests;

public class GetSearchCandidatesTests
{
private static List<string> GetCandidates(string name)
{
return DataObjects.GetSearchCandidates(name);
}

[Theory]
[InlineData("The Legend of Zelda", "The Legend of Zelda", "Legend of Zelda", "Legend of Zelda, The")]
[InlineData("Legend of Zelda, The", "Legend of Zelda, The", "Legend of Zelda", "The Legend of Zelda")]
[InlineData("Final Fantasy IV", "Final Fantasy IV", "Final Fantasy 4", "Final Fantasy IV")]
[InlineData("Resident Evil - Code: Veronica", "Resident Evil - Code: Veronica", "Resident Evil: Code: Veronica", "Resident Evil - Code: Veronica")]
[InlineData("Sonic (USA)", "Sonic (USA)", "Sonic", "Sonic (USA)")]
[InlineData("Mega Man v1.2", "Mega Man v1.2", "Mega Man", "Mega Man v1.2")]
[InlineData("Street Fighter Rev A", "Street Fighter Rev A", "Street Fighter", "Street Fighter Rev A")]
public void GeneratesExpectedCandidates(string input, string expected1, string expected2, string expected3)
{
List<string> candidates = GetCandidates(input);

Assert.Contains(expected1, candidates);
Assert.Contains(expected2, candidates);
Assert.Contains(expected3, candidates);
}

[Fact]
public void ReturnsEmptyListForBlankName()
{
List<string> candidates = GetCandidates(" ");
Assert.Empty(candidates);
}

[Theory]
[InlineData("Resident Evil - Code: Veronica", "Resident Evil Code: Veronica")]
[InlineData("Metal Gear Solid: The Twin Snakes", "Metal Gear Solid The Twin Snakes")]
[InlineData("Prince of Persia - The Sands of Time", "Prince of Persia The Sands of Time")]
public void DropsDelimitersCorrectly(string input, string expectedWithDelimiterDrop)
{
List<string> candidates = GetCandidates(input);

Assert.Contains(expectedWithDelimiterDrop, candidates);
}

[Theory]
[InlineData("Game 1", "Game One")]
[InlineData("Mega Man 2", "Mega Man Two")]
[InlineData("Final Fantasy VII", "Final Fantasy VII", "Final Fantasy 7", "Final Fantasy Seven")]
[InlineData("Take 2", "Take Two")]
[InlineData("Top 10", "Top Ten")]
[InlineData("The Room 3", "The Room Three")]
public void ConvertsNumbersToWords(string input, params string[] expectedCandidates)
{
List<string> candidates = GetCandidates(input);

foreach (string expected in expectedCandidates)
{
Assert.Contains(expected, candidates);
}
}

[Theory]
[InlineData("Game One", "Game 1")]
[InlineData("Mega Man Two", "Mega Man 2")]
[InlineData("Final Fantasy Seven", "Final Fantasy 7")]
[InlineData("Take Twenty One", "Take 21")]
[InlineData("Top Ten", "Top 10")]
[InlineData("The Room Three", "The Room 3")]
public void ConvertsWordsToNumbers(string input, string expectedCandidate)
{
List<string> candidates = GetCandidates(input);

Assert.Contains(expectedCandidate, candidates);
}

[Theory]
[InlineData("Resident Evil 5", "Resident Evil Five")]
[InlineData("Portal 2", "Portal Two")]
[InlineData("Call of Duty Modern Warfare 3", "Call of Duty Modern Warfare Three")]
public void BidirectionalNumberConversion(string input, string expectedCandidate)
{
List<string> candidates = GetCandidates(input);

Assert.Contains(expectedCandidate, candidates);
}

[Theory]
[InlineData("Star Wars: Episode 1 - Racer", "Star Wars: Episode I - Racer")]
[InlineData("Game 2", "Game II")]
[InlineData("Final Fantasy 7", "Final Fantasy VII")]
[InlineData("Chapter 3", "Chapter III")]
[InlineData("Volume 5", "Volume V")]
[InlineData("Part 10", "Part X")]
public void ConvertsNumbersToRomanNumerals(string input, string expectedCandidate)
{
List<string> candidates = GetCandidates(input);

Assert.Contains(expectedCandidate, candidates);
}

[Theory]
[InlineData("Star Wars: Episode I - Racer", "Star Wars: Episode 1 - Racer")]
[InlineData("Game II", "Game 2")]
[InlineData("Final Fantasy VII", "Final Fantasy 7")]
[InlineData("Chapter III", "Chapter 3")]
[InlineData("Volume V", "Volume 5")]
[InlineData("Part X", "Part 10")]
public void ConvertsRomanNumeralsToNumbers(string input, string expectedCandidate)
{
List<string> candidates = GetCandidates(input);

Assert.Contains(expectedCandidate, candidates);
}
}
26 changes: 26 additions & 0 deletions hasheous-lib.Tests/hasheous-lib.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>hasheous_lib.Tests</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\hasheous-lib\hasheous-lib.csproj" />
</ItemGroup>

</Project>
Loading
Loading