Skip to content

Commit

Permalink
T #5 Created tests project
Browse files Browse the repository at this point in the history
  • Loading branch information
HueByte committed Sep 16, 2022
1 parent 8574ee7 commit 05c3d6b
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 9 deletions.
33 changes: 33 additions & 0 deletions Huppy/Huppy.Tests/Huppy.IntegrationTests/Huppy.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Xunit.DependencyInjection" Version="8.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Huppy.App\Huppy.App.csproj" />
<ProjectReference Include="..\..\Huppy.Core\Huppy.Core.csproj" />
<ProjectReference Include="..\..\Huppy.Infrastructure\Huppy.Infrastructure.csproj" />
<ProjectReference Include="..\..\Huppy.Kernel\Huppy.Kernel.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -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));
}
}
44 changes: 44 additions & 0 deletions Huppy/Huppy.Tests/Huppy.IntegrationTests/Startup.cs
Original file line number Diff line number Diff line change
@@ -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<Program>();
})
.ConfigureServices(services =>
{
_ = new ModuleConfigurator(services)
.AddAppSettings(appSettings)
.AddLogger(Log.Logger)
.AddDiscord()
.AddServices()
.AddDatabase()
.AddHttpClients()
.AddMiddlewares();

services.AddHostedService<HuppyHostedService>();
})
.ConfigureLogging(ctx => ctx.ClearProviders())
.UseSerilog(Log.Logger);
}
}
6 changes: 6 additions & 0 deletions Huppy/Huppy.Tests/Huppy.IntegrationTests/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
global using Xunit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
32 changes: 23 additions & 9 deletions Huppy/Huppy.sln
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit 05c3d6b

Please sign in to comment.