diff --git a/Huppy/Huppy.Tests/Huppy.IntegrationTests/Huppy.Tests.csproj b/Huppy/Huppy.Tests/Huppy.IntegrationTests/Huppy.Tests.csproj new file mode 100644 index 0000000..fbb5307 --- /dev/null +++ b/Huppy/Huppy.Tests/Huppy.IntegrationTests/Huppy.Tests.csproj @@ -0,0 +1,33 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + diff --git a/Huppy/Huppy.Tests/Huppy.IntegrationTests/Services/UrbanServiceTests.cs b/Huppy/Huppy.Tests/Huppy.IntegrationTests/Services/UrbanServiceTests.cs new file mode 100644 index 0000000..b6ac503 --- /dev/null +++ b/Huppy/Huppy.Tests/Huppy.IntegrationTests/Services/UrbanServiceTests.cs @@ -0,0 +1,23 @@ +using Huppy.Core.Interfaces.IServices; + +namespace Huppy.Tests.Services; + +public class UrbanServiceTests +{ + private readonly IUrbanService _urbanService; + public UrbanServiceTests(IUrbanService urbanService) + { + _urbanService = urbanService; + } + + [Theory] + [InlineData("Test")] + [InlineData("Bonk")] + public async Task GetDefinitionTests(string term) + { + var result = (await _urbanService.GetDefinition(term)).List!.OrderByDescending(e => e.ThumbsUp - e.ThumbsDown).FirstOrDefault(); + + Assert.NotNull(result); + Assert.False(string.IsNullOrEmpty(result?.Definition)); + } +} diff --git a/Huppy/Huppy.Tests/Huppy.IntegrationTests/Startup.cs b/Huppy/Huppy.Tests/Huppy.IntegrationTests/Startup.cs new file mode 100644 index 0000000..7613f5a --- /dev/null +++ b/Huppy/Huppy.Tests/Huppy.IntegrationTests/Startup.cs @@ -0,0 +1,44 @@ +using Huppy.App.Configuration; +using Huppy.Core.Services.Huppy; +using Huppy.Core.Utilities; +using Huppy.Kernel; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.VisualStudio.TestPlatform.TestHost; +using Serilog; + +namespace Huppy.Tests; + +public class Startup +{ + public void ConfigureHost(IHostBuilder hostBuilder) + { + var appSettings = AppSettings.IsCreated + ? AppSettings.Load() + : AppSettings.Create(); + + Log.Logger = SerilogConfigurator.ConfigureLogger(appSettings); + + hostBuilder.ConfigureHostConfiguration(host => + { + host.AddUserSecrets(); + }) + .ConfigureServices(services => + { + _ = new ModuleConfigurator(services) + .AddAppSettings(appSettings) + .AddLogger(Log.Logger) + .AddDiscord() + .AddServices() + .AddDatabase() + .AddHttpClients() + .AddMiddlewares(); + + services.AddHostedService(); + }) + .ConfigureLogging(ctx => ctx.ClearProviders()) + .UseSerilog(Log.Logger); + } +} diff --git a/Huppy/Huppy.Tests/Huppy.IntegrationTests/Usings.cs b/Huppy/Huppy.Tests/Huppy.IntegrationTests/Usings.cs new file mode 100644 index 0000000..2ac56dd --- /dev/null +++ b/Huppy/Huppy.Tests/Huppy.IntegrationTests/Usings.cs @@ -0,0 +1,6 @@ +global using Xunit; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; \ No newline at end of file diff --git a/Huppy/Huppy.sln b/Huppy/Huppy.sln index 2e6fd87..ab868ee 100644 --- a/Huppy/Huppy.sln +++ b/Huppy/Huppy.sln @@ -1,24 +1,25 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30114.105 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32901.215 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Huppy.App", "Huppy.App\Huppy.App.csproj", "{63A53A9E-3A99-47A7-BC56-757C4C484789}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Huppy.App", "Huppy.App\Huppy.App.csproj", "{63A53A9E-3A99-47A7-BC56-757C4C484789}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Huppy.Core", "Huppy.Core\Huppy.Core.csproj", "{24DBA258-A21A-4C73-B2E4-1F095F6629D2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Huppy.Core", "Huppy.Core\Huppy.Core.csproj", "{24DBA258-A21A-4C73-B2E4-1F095F6629D2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Huppy.Infrastructure", "Huppy.Infrastructure\Huppy.Infrastructure.csproj", "{63DCCC50-7380-445C-AF41-3DBD2A7FE953}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Huppy.Infrastructure", "Huppy.Infrastructure\Huppy.Infrastructure.csproj", "{63DCCC50-7380-445C-AF41-3DBD2A7FE953}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Huppy.Kernel", "Huppy.Kernel\Huppy.Kernel.csproj", "{DFC4F96F-AAD1-406B-B9C7-21CC2FAF19DE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Huppy.Kernel", "Huppy.Kernel\Huppy.Kernel.csproj", "{DFC4F96F-AAD1-406B-B9C7-21CC2FAF19DE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Huppy.Tests", "Huppy.Tests", "{94229B5C-EF82-4DD9-86F9-C34E9BC329A5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Huppy.Tests", "Huppy.Tests\Huppy.IntegrationTests\Huppy.Tests.csproj", "{A279AB89-9BAB-4BBC-AFB7-5E7BC7EFB3FB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {63A53A9E-3A99-47A7-BC56-757C4C484789}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {63A53A9E-3A99-47A7-BC56-757C4C484789}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -36,5 +37,18 @@ Global {DFC4F96F-AAD1-406B-B9C7-21CC2FAF19DE}.Debug|Any CPU.Build.0 = Debug|Any CPU {DFC4F96F-AAD1-406B-B9C7-21CC2FAF19DE}.Release|Any CPU.ActiveCfg = Release|Any CPU {DFC4F96F-AAD1-406B-B9C7-21CC2FAF19DE}.Release|Any CPU.Build.0 = Release|Any CPU + {A279AB89-9BAB-4BBC-AFB7-5E7BC7EFB3FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A279AB89-9BAB-4BBC-AFB7-5E7BC7EFB3FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A279AB89-9BAB-4BBC-AFB7-5E7BC7EFB3FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A279AB89-9BAB-4BBC-AFB7-5E7BC7EFB3FB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A279AB89-9BAB-4BBC-AFB7-5E7BC7EFB3FB} = {94229B5C-EF82-4DD9-86F9-C34E9BC329A5} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2C7FDC06-79CF-4B72-A87E-E29220569EE3} EndGlobalSection EndGlobal