Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
d4n3436 committed Dec 28, 2023
1 parent 9afe437 commit 1306a7b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/Fergun.Tests/Converters/MicrosoftVoiceConverterTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Bogus;
using GTranslate.Translators;
using Moq;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net;
Expand All @@ -11,13 +10,13 @@
using GTranslate;
using Moq.Protected;
using Xunit;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Discord;
using Fergun.Converters;
using System;
using Bogus.DataSets;
using Discord.Interactions;
using System.Text;

namespace Fergun.Tests.Converters;

Expand All @@ -35,7 +34,7 @@ public void MicrosoftVoiceConverter_GetDiscordType_Returns_String()

[Theory]
[MemberData(nameof(GetMicrosoftVoiceTestData))]
public async Task MicrosoftVoiceConverter_ReadAsync_Retuns_Successful_Result(MicrosoftVoice voice, bool isDefault)
public async Task MicrosoftVoiceConverter_ReadAsync_Returns_Successful_Result(MicrosoftVoice voice, bool isDefault)
{
var microsoftTranslator = CreateMockedMicrosoftTranslator(() =>
{
Expand Down Expand Up @@ -77,7 +76,7 @@ public async Task MicrosoftVoiceConverter_ReadAsync_Retuns_Successful_Result(Mic
[InlineData(null, "en")]
[InlineData("", "es")]
[InlineData("\u200b", "it")]
public async Task MicrosoftVoiceConverter_ReadAsync_Retuns_Unsuccessful_Result(string voice, string locale)
public async Task MicrosoftVoiceConverter_ReadAsync_Returns_Unsuccessful_Result(string? voice, string locale)
{
var microsoftTranslator = CreateMockedMicrosoftTranslator(() => Task.FromCanceled<HttpResponseMessage>(CancellationToken.None));
var localizer = Utils.CreateMockedLocalizer<SharedResource>();
Expand All @@ -96,7 +95,7 @@ public async Task MicrosoftVoiceConverter_ReadAsync_Retuns_Unsuccessful_Result(s
contextMock.SetupGet(x => x.Interaction).Returns(() => interactionMock.Object);

var optionMock = new Mock<IApplicationCommandInteractionDataOption>();
optionMock.SetupGet(x => x.Value).Returns(() => voice);
optionMock.SetupGet(x => x.Value).Returns(() => voice!);

var result = await converter.ReadAsync(contextMock.Object, optionMock.Object, services);

Expand All @@ -122,7 +121,7 @@ private static MicrosoftTranslator CreateMockedMicrosoftTranslator(Func<Task<Htt

private static HttpResponseMessage GetResponseMessage(byte[] data) => new(HttpStatusCode.OK) { Content = new ByteArrayContent(data) };

public static IEnumerable<object[]> GetMicrosoftVoiceTestData()
public static TheoryData<MicrosoftVoice, bool> GetMicrosoftVoiceTestData()
{
var faker = new Faker();
var fakeVoices = faker.MakeLazy(10, () =>
Expand All @@ -133,10 +132,11 @@ public static IEnumerable<object[]> GetMicrosoftVoiceTestData()
string genderStr = gender.ToString();

return new MicrosoftVoice(displayName, $"{locale}-{displayName}Neural", genderStr, locale);
}).Select(x => new object[] { x, false });
}).Select(x => (x, false));

return MicrosoftTranslator.DefaultVoices.Values
.Select(x => new object[] { x, true })
.Concat(fakeVoices);
.Select(x => (x, true))
.Concat(fakeVoices)
.ToTheoryData();
}
}

0 comments on commit 1306a7b

Please sign in to comment.