Skip to content

Commit

Permalink
Merge pull request #7 from BibleTalkAI/add-tests
Browse files Browse the repository at this point in the history
Add Tests
  • Loading branch information
cdorst authored Jun 4, 2024
2 parents 2bbb026 + 169dde7 commit b3ca56f
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@ jobs:

- name: Build
run: dotnet build --configuration Release

- name: Test
run: dotnet test 'BibleTalkAI.LanguageOptions.Tests' --configuration Release --no-restore --no-build --logger trx --results-directory TestResults

- name: Upload dotnet test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: TestResults
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
11 changes: 11 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,16 @@ jobs:
- name: Build
run: dotnet build --configuration Release

- name: Test
run: dotnet test 'BibleTalkAI.LanguageOptions.Tests' --configuration Release --no-restore --no-build --logger trx --results-directory TestResults

- name: Upload dotnet test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: TestResults
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}

- name: Push to NuGet
run: dotnet nuget push **/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<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="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BibleTalkAI.LanguageOptions\BibleTalkAI.LanguageOptions.csproj" />
</ItemGroup>

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

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace BibleTalkAI.LanguageOptions.Tests;

public class LanguagePreferenceServiceTests
{
[Fact]
public void GetLanguagePreference_ReturnsLanguagePreference()
{
// Arrange
var languagePreferencesService = new LanguagePreferencesService();
var languagePreferenceOption = 1;

// Act
var languagePreference = languagePreferencesService.GetLanguagePreference(languagePreferenceOption);

// Assert
Assert.NotNull(languagePreference);
Assert.Equal("en-US", languagePreference.GatherLanguage);
Assert.Equal("Polly.Matthew-Neural", languagePreference.SayVoice);
Assert.Equal("en-US", languagePreference.SayLanguage);
Assert.Equal("English", languagePreference.LanguageNameInEnglish);
}

[Fact]
public void GetLanguagePreference_ReturnsNull_WhenNotFound()
{
// Arrange
var languagePreferencesService = new LanguagePreferencesService();
var languagePreferenceOption = -1;

// Act
var languagePreference = languagePreferencesService.GetLanguagePreference(languagePreferenceOption);

// Assert
Assert.Null(languagePreference);
}
}
79 changes: 79 additions & 0 deletions BibleTalkAI.LanguageOptions.Tests/LanguagePreferencesTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
namespace BibleTalkAI.LanguageOptions.Tests;

public class LanguagePreferencesTests
{
[Fact]
public void Language_Has_45_Options()
{
// Arrange
var languagePreferences = LanguagePreferences.Languages;

// Act
var count = languagePreferences.Count;

// Assert
Assert.Equal(45, count);
}

[Theory]
[InlineData(1, "en-US", "Polly.Matthew-Neural", "en-US", "English")]
[InlineData(2, "cmn-Hans-CN", "Google.cmn-CN-Wavenet-B", "cmn-CN", "Chinese Mandarin")]
[InlineData(3, "hi-IN", "Google.hi-IN-Wavenet-B", "hi-IN", "Hindi")]
[InlineData(4, "es-US", "Polly.Pedro-Neural", "es-US", "Spanish")]
[InlineData(5, "ar-MA", "Google.ar-XA-Wavenet-B", "ar-XA", "Arabic")]
[InlineData(6, "ms-MY", "Google.ms-MY-Wavenet-B", "ms-MY", "Malay")]
[InlineData(7, "fr-FR", "Polly.Remi-Neural", "fr-FR", "French")]
[InlineData(8, "pt-BR", "Polly.Thiago-Neural", "pt-BR", "Portuguese")]
[InlineData(9, "ru-RU", "Google.ru-RU-Wavenet-B", "ru-RU", "Russian")]
[InlineData(10, "id-ID", "Google.id-ID-Wavenet-B", "id-ID", "Indonesian")]
[InlineData(11, "de-DE", "Polly.Daniel-Neural", "de-DE", "German")]
[InlineData(12, "ja-JP", "Polly.Takumi-Neural", "ja-JP", "Japanese")]
[InlineData(14, "mr-IN", "Google.mr-IN-Wavenet-B", "mr-IN", "Marathi")]
[InlineData(15, "te-IN", "Google.te-IN-Standard-B", "te-IN", "Telugu")]
[InlineData(16, "ko-KR", "Google.ko-KR-Wavenet-C", "ko-KR", "Korean")]
[InlineData(17, "vi-VN", "Google.vi-VN-Wavenet-B", "vi-VN", "Vietnamese")]
[InlineData(18, "ta-IN", "Google.ta-IN-Wavenet-D", "ta-IN", "Tamil")]
[InlineData(19, "tr-TR", "Google.tr-TR-Wavenet-B", "tr-TR", "Turkish")]
[InlineData(20, "yue-Hant-HK", "Google.yue-HK-Standard-B", "yue-HK", "Chinese Cantonese")]
[InlineData(21, "it-IT", "Polly.Adriano-Neural", "it-IT", "Italian")]
[InlineData(22, "pl-PL", "Google.pl-PL-Wavenet-B", "pl-PL", "Polish")]
[InlineData(23, "ml-IN", "Google.ml-IN-Wavenet-D", "ml-IN", "Malayalam")]
[InlineData(24, "fil-PH", "Google.fil-PH-Wavenet-B", "fil-PH", "Filipino")]
[InlineData(25, "nl-NL", "Google.nl-NL-Wavenet-B", "nl-NL", "Dutch")]
[InlineData(26, "sv-SE", "Google.sv-SE-Wavenet-C", "sv-SE", "Swedish")]
[InlineData(27, "he-IL", "Google.he-IL-Wavenet-B", "he-IL", "Hebrew")]
[InlineData(28, "da-DK", "Google.da-DK-Wavenet-C", "da-DK", "Danish")]
[InlineData(29, "nb-NO", "Google.nb-NO-Wavenet-B", "nb-NO", "Norwegian")]
[InlineData(30, "lt-LT", "Google.lt-LT-Standard-A", "lt-LT", "Lithuanian")]
[InlineData(31, "lv-LV", "Google.lv-LV-Standard-A", "lv-LV", "Latvian")]
[InlineData(32, "af-ZA", "Google.af-ZA-Standard-A", "af-ZA", "Afrikaans")]
[InlineData(33, "eu-ES", "Google.eu-ES-Standard-A", "eu-ES", "Basque")]
[InlineData(34, "bg-BG", "Google.bg-BG-Standard-A", "bg-BG", "Bulgarian")]
[InlineData(35, "ca-ES", "Polly.Arlet-Neural", "ca-ES", "Catalan")]
[InlineData(36, "cs-CZ", "Google.cs-CZ-Wavenet-A", "cs-CZ", "Czech")]
[InlineData(37, "fi-FI", "Polly.Suvi-Neural", "fi-FI", "Finnish")]
[InlineData(38, "gl-ES", "Google.gl-ES-Standard-A", "gl-ES", "Galician")]
[InlineData(39, "el-GR", "Google.el-GR-Wavenet-A", "el-GR", "Greek")]
[InlineData(40, "hu-HU", "Google.hu-HU-Wavenet-A", "hu-HU", "Hungarian")]
[InlineData(41, "is-IS", "Polly.Karl", "is-IS", "Icelandic")]
[InlineData(42, "ro-RO", "Google.ro-RO-Wavenet-A", "ro-RO", "Romanian")]
[InlineData(43, "sr-RS", "Google.sr-RS-Standard-A", "sr-RS", "Serbian")]
[InlineData(44, "sk-SK", "Google.sk-SK-Wavenet-A", "sk-SK", "Slovak")]
[InlineData(45, "th-TH", "Google.th-TH-Standard-A", "th-TH", "Thai")]
[InlineData(46, "uk-UA", "Google.uk-UA-Wavenet-A", "uk-UA", "Ukrainian")]
public void GetLanguagePreference_ReturnsLanguagePreference(int languagePreferenceOption, string gatherLanguage, string sayVoice, string sayLanguage, string languageNameInEnglish)
{
// Arrange
var languagePreferencesService = new LanguagePreferencesService();

// Act
var languagePreference = languagePreferencesService.GetLanguagePreference(languagePreferenceOption);

// Assert
Assert.NotNull(languagePreference);
Assert.Equal(gatherLanguage, languagePreference.GatherLanguage);
Assert.Equal(sayVoice, languagePreference.SayVoice);
Assert.Equal(sayLanguage, languagePreference.SayLanguage);
Assert.Equal(languageNameInEnglish, languagePreference.LanguageNameInEnglish);
}
}
8 changes: 7 additions & 1 deletion BibleTalkAI.LanguageOptions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34518.117
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BibleTalkAI.LanguageOptions", "BibleTalkAI.LanguageOptions\BibleTalkAI.LanguageOptions.csproj", "{3FA8DF4B-7E7F-41FD-ACC8-B9D01B2CD73A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BibleTalkAI.LanguageOptions", "BibleTalkAI.LanguageOptions\BibleTalkAI.LanguageOptions.csproj", "{3FA8DF4B-7E7F-41FD-ACC8-B9D01B2CD73A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{203BB41E-2224-4D66-9904-3E5ED9F3E3D8}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -27,6 +27,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\publish.yml = .github\workflows\publish.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BibleTalkAI.LanguageOptions.Tests", "BibleTalkAI.LanguageOptions.Tests\BibleTalkAI.LanguageOptions.Tests.csproj", "{57EA7698-D439-4430-8755-68FAE79FEC1A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -37,6 +39,10 @@ Global
{3FA8DF4B-7E7F-41FD-ACC8-B9D01B2CD73A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FA8DF4B-7E7F-41FD-ACC8-B9D01B2CD73A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FA8DF4B-7E7F-41FD-ACC8-B9D01B2CD73A}.Release|Any CPU.Build.0 = Release|Any CPU
{57EA7698-D439-4430-8755-68FAE79FEC1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{57EA7698-D439-4430-8755-68FAE79FEC1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57EA7698-D439-4430-8755-68FAE79FEC1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57EA7698-D439-4430-8755-68FAE79FEC1A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit b3ca56f

Please sign in to comment.