Skip to content

Commit

Permalink
Add MagicOnion.Server.InternalTesting
Browse files Browse the repository at this point in the history
  • Loading branch information
mayuki committed Nov 20, 2024
1 parent 8b99bb4 commit 81feccc
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 166 deletions.
7 changes: 7 additions & 0 deletions MagicOnion.sln
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicOnion.Server.JsonTrans
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicOnion.Server.JsonTranscoding.Tests", "tests\MagicOnion.Server.JsonTranscoding.Tests\MagicOnion.Server.JsonTranscoding.Tests.csproj", "{3FE94073-95E0-4006-ADD6-BBE1FAFBAE75}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicOnion.Server.InternalTesting", "tests\MagicOnion.Server.InternalTesting\MagicOnion.Server.InternalTesting.csproj", "{1A958468-D9B8-42B0-99CF-0F9358CD0434}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -279,6 +281,10 @@ Global
{3FE94073-95E0-4006-ADD6-BBE1FAFBAE75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FE94073-95E0-4006-ADD6-BBE1FAFBAE75}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FE94073-95E0-4006-ADD6-BBE1FAFBAE75}.Release|Any CPU.Build.0 = Release|Any CPU
{1A958468-D9B8-42B0-99CF-0F9358CD0434}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A958468-D9B8-42B0-99CF-0F9358CD0434}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A958468-D9B8-42B0-99CF-0F9358CD0434}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A958468-D9B8-42B0-99CF-0F9358CD0434}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -328,6 +334,7 @@ Global
{CDBB141A-E0A9-4FD8-8260-1FB1E95C4E80} = {F1FD52DD-E8A4-4CF0-A857-1A22443A0324}
{8A84D0D5-5AD5-4A76-895A-737AEBBDAA27} = {1987061F-8970-4018-8D58-6932961C9EB4}
{3FE94073-95E0-4006-ADD6-BBE1FAFBAE75} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0}
{1A958468-D9B8-42B0-99CF-0F9358CD0434} = {7ACC27E8-8FBE-4807-B91F-B89AF3CFF7E0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D5B2E7E3-B727-40A1-BE68-7BAC9B9DE2FE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using MagicOnion.Internal;
using MagicOnion.Serialization;
using MagicOnion.Server.Hubs;
using MagicOnionTestServer;
using Microsoft.AspNetCore.Mvc.Testing;

namespace MagicOnion.Integration.Tests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<ProjectReference Include="..\..\src\MagicOnion.Client.SourceGenerator\MagicOnion.Client.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\..\src\MagicOnion.Client\MagicOnion.Client.csproj" />
<ProjectReference Include="..\..\src\MagicOnion.Server\MagicOnion.Server.csproj" />
<ProjectReference Include="..\MagicOnion.Server.InternalTesting\MagicOnion.Server.InternalTesting.csproj" />
<ProjectReference Include="..\samples\MagicOnionTestServer\MagicOnionTestServer.csproj" />
</ItemGroup>

Expand Down
44 changes: 0 additions & 44 deletions tests/MagicOnion.Integration.Tests/MagicOnionApplicationFactory.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using MagicOnion.Client;
using MagicOnion.Client.DynamicClient;
using MagicOnion.Server.Hubs;
using MagicOnionTestServer;
using Microsoft.AspNetCore.Mvc.Testing;

namespace MagicOnion.Integration.Tests;
Expand Down
1 change: 0 additions & 1 deletion tests/MagicOnion.Integration.Tests/SerializerUnaryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using MagicOnion.Serialization;
using MagicOnion.Serialization.MessagePack;
using MagicOnion.Server;
using MagicOnionTestServer;
using Microsoft.AspNetCore.Mvc.Testing;

#pragma warning disable CS1998 // This async method lacks 'await' operators and will run synchronously
Expand Down
1 change: 1 addition & 0 deletions tests/MagicOnion.Integration.Tests/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

global using Grpc.Core;
global using MessagePack;
global using MagicOnion.Server.InternalTesting;
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<ProjectReference Include="..\..\src\MagicOnion.Client.SourceGenerator\MagicOnion.Client.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\..\src\MagicOnion.Serialization.MemoryPack\MagicOnion.Serialization.MemoryPack.csproj" />
<ProjectReference Include="..\..\src\MagicOnion\MagicOnion.csproj" />
<ProjectReference Include="..\MagicOnion.Server.InternalTesting\MagicOnion.Server.InternalTesting.csproj" />
<ProjectReference Include="..\samples\MagicOnionTestServer\MagicOnionTestServer.csproj" />
</ItemGroup>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using MagicOnion.Client;
using MagicOnion.Server;
using MagicOnion.Server.Hubs;
using MagicOnionTestServer;
using MemoryPack;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using MagicOnion.Client;
using MagicOnion.Serialization.MessagePack;
using MagicOnion.Server;
using MagicOnionTestServer;
using MemoryPack;
using MessagePack;
using Microsoft.AspNetCore.Mvc.Testing;
Expand Down
1 change: 1 addition & 0 deletions tests/MagicOnion.Serialization.MemoryPack.Tests/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

global using Grpc.Core;
global using MessagePack;
global using MagicOnion.Server.InternalTesting;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.Testing" />
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MagicOnion.Server\MagicOnion.Server.csproj" />
<ProjectReference Include="..\samples\MagicOnionTestServer\MagicOnionTestServer.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Builder;

namespace MagicOnion.Server.Tests;
namespace MagicOnion.Server.InternalTesting;

#pragma warning disable CS1998
public class MagicOnionApplicationFactory<TServiceImplementation> : MagicOnionApplicationFactory
Expand All @@ -16,7 +16,7 @@ protected override IEnumerable<Type> GetServiceImplementationTypes()
}
}

public abstract class MagicOnionApplicationFactory : WebApplicationFactory<MagicOnionTestServer.Program>
public abstract class MagicOnionApplicationFactory : WebApplicationFactory<Program>
{
public const string ItemsKey = "MagicOnionApplicationFactory.Items";
public ConcurrentDictionary<string, object> Items => Services.GetRequiredKeyedService<ConcurrentDictionary<string, object>>(ItemsKey);
Expand Down Expand Up @@ -49,7 +49,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)

protected abstract IEnumerable<Type> GetServiceImplementationTypes();

public WebApplicationFactory<MagicOnionTestServer.Program> WithMagicOnionOptions(Action<MagicOnionOptions> configure)
public WebApplicationFactory<Program> WithMagicOnionOptions(Action<MagicOnionOptions> configure)
{
return this.WithWebHostBuilder(x =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
</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" />
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<ProjectReference Include="..\..\src\MagicOnion.Client\MagicOnion.Client.csproj" />
<ProjectReference Include="..\..\src\MagicOnion.Server.Redis\MagicOnion.Server.Redis.csproj" />
<ProjectReference Include="..\..\src\MagicOnion.Server\MagicOnion.Server.csproj" />
<ProjectReference Include="..\MagicOnion.Server.InternalTesting\MagicOnion.Server.InternalTesting.csproj" />
<ProjectReference Include="..\samples\MagicOnionTestServer\MagicOnionTestServer.csproj" />
</ItemGroup>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Grpc.Net.Client;
using MagicOnion.Client;
using MagicOnion.Server.InternalTesting;
using Microsoft.AspNetCore.Mvc.Testing;
using NSubstitute;

namespace MagicOnion.Server.Redis.Tests;

public class RedisGroupFunctionalTest : IClassFixture<MagicOnionApplicationFactory<RedisGroupFunctionalTestHub>>, IClassFixture<TemporaryRedisServerFixture>
{
readonly WebApplicationFactory<MagicOnionTestServer.Program> factory;
readonly WebApplicationFactory<MagicOnionTestServer.Program> factory2;
readonly WebApplicationFactory<Program> factory;
readonly WebApplicationFactory<Program> factory2;
readonly TemporaryRedisServerFixture redisServer;

public RedisGroupFunctionalTest(MagicOnionApplicationFactory<RedisGroupFunctionalTestHub> factory, TemporaryRedisServerFixture redisServer)
Expand Down
4 changes: 1 addition & 3 deletions tests/MagicOnion.Server.Tests/MagicOnion.Server.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.Testing" />
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="xunit" />
Expand All @@ -28,6 +25,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\MagicOnion.Client\MagicOnion.Client.csproj" />
<ProjectReference Include="..\..\src\MagicOnion.Server\MagicOnion.Server.csproj" />
<ProjectReference Include="..\MagicOnion.Server.InternalTesting\MagicOnion.Server.InternalTesting.csproj" />
<ProjectReference Include="..\samples\AuthSample\AuthSample.csproj" />
<ProjectReference Include="..\samples\MagicOnionEngineTest\MagicOnionEngineTest.csproj" />
<ProjectReference Include="..\samples\MagicOnionTestServer\MagicOnionTestServer.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion tests/MagicOnion.Server.Tests/MagicOnionMetricsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace MagicOnion.Server.Tests;

public class MagicOnionMetricsTest : IClassFixture<MagicOnionApplicationFactory<MagicOnionMetricsTestHub>>
{
readonly WebApplicationFactory<MagicOnionTestServer.Program> factory;
readonly WebApplicationFactory<Program> factory;
readonly TestMeterFactory meterFactory;

public MagicOnionMetricsTest(MagicOnionApplicationFactory<MagicOnionMetricsTestHub> fixture)
Expand Down
2 changes: 1 addition & 1 deletion tests/MagicOnion.Server.Tests/RawBytesResponseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace MagicOnion.Server.Tests;

public class RawBytesResponseTest : IClassFixture<MagicOnionApplicationFactory<RawBytesResponseTestService>>
{
readonly WebApplicationFactory<MagicOnionTestServer.Program> factory;
readonly WebApplicationFactory<Program> factory;

public RawBytesResponseTest(MagicOnionApplicationFactory<RawBytesResponseTestService> factory)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/MagicOnion.Server.Tests/UnaryServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace MagicOnion.Server.Tests;
public class UnaryServiceTest_ReturnExceptionStackTrace : IClassFixture<MagicOnionApplicationFactory<UnaryTestService>>
{
readonly List<string> logs;
readonly WebApplicationFactory<MagicOnionTestServer.Program> factory;
readonly WebApplicationFactory<Program> factory;

public UnaryServiceTest_ReturnExceptionStackTrace(MagicOnionApplicationFactory<UnaryTestService> factory)
{
Expand Down Expand Up @@ -77,7 +77,7 @@ public async Task Throw_TwoParameterReturnNil()
public class UnaryServiceTest : IClassFixture<MagicOnionApplicationFactory<UnaryTestService>>
{
readonly List<string> logs;
readonly WebApplicationFactory<MagicOnionTestServer.Program> factory;
readonly WebApplicationFactory<Program> factory;

public UnaryServiceTest(MagicOnionApplicationFactory<UnaryTestService> factory)
{
Expand Down
1 change: 1 addition & 0 deletions tests/MagicOnion.Server.Tests/_GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
global using FluentAssertions;
global using MagicOnion.Server.InternalTesting;
global using Xunit;
3 changes: 2 additions & 1 deletion tests/samples/MagicOnionTestServer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace MagicOnionTestServer;
// ReSharper disable once CheckNamespace
namespace MagicOnion.Server.InternalTesting;

/// <summary>
/// This project exists to be used by test projects that uses WebApplicationFactory.
Expand Down

0 comments on commit 81feccc

Please sign in to comment.