-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix settings constructor backward compatibility issue (#214)
* Fix .ctor backward compatibility issue * Add Akka integration spec * Use common.props for nuget package versions * Add API Approver spec
- Loading branch information
Showing
10 changed files
with
944 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using ApprovalTests; | ||
using ApprovalTests.Reporters; | ||
using PublicApiGenerator; | ||
using Xunit; | ||
|
||
namespace Hyperion.API.Tests | ||
{ | ||
#if(DEBUG) | ||
[UseReporter(typeof(DiffReporter), typeof(AllFailingTestsClipboardReporter))] | ||
#else | ||
[UseReporter(typeof(DiffReporter))] | ||
#endif | ||
public class CoreApiSpec | ||
{ | ||
[Fact] | ||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public void ApproveApi() | ||
{ | ||
var publicApi = Filter(typeof(Serializer).Assembly.GeneratePublicApi()); | ||
Approvals.Verify(publicApi); | ||
} | ||
|
||
static string Filter(string text) | ||
{ | ||
return string.Join(Environment.NewLine, text.Split(new[] | ||
{ | ||
Environment.NewLine | ||
}, StringSplitOptions.RemoveEmptyEntries) | ||
.Where(l => | ||
!l.StartsWith("[assembly: ReleaseDateAttribute(") | ||
&& !l.StartsWith("[assembly: System.Security") | ||
&& !l.StartsWith("[assembly: System.Runtime.Versioning.TargetFramework(")) | ||
.Where(l => !string.IsNullOrWhiteSpace(l)) | ||
); | ||
} | ||
} | ||
} |
693 changes: 693 additions & 0 deletions
693
src/Hyperion.API.Tests/CoreApiSpec.ApproveApi.approved.txt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="..\common.props" /> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net461;netcoreapp3.1;net5.0</TargetFrameworks> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="ApprovalTests" Version="5.4.7" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" /> | ||
<PackageReference Include="PublicApiGenerator" Version="10.2.0" /> | ||
<PackageReference Include="xunit" Version="$(XunitVersion)" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVersion)"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="1.3.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Hyperion\Hyperion.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
31 changes: 31 additions & 0 deletions
31
src/Hyperion.Akka.Integration.Tests/Hyperion.Akka.Integration.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="..\common.props" /> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net461;netcoreapp3.1;net5.0</TargetFrameworks> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Akka" Version="$(AkkaVersion)" /> | ||
<PackageReference Include="Akka.Serialization.Hyperion" Version="$(AkkaVersion)" /> | ||
<PackageReference Include="Akka.TestKit.Xunit2" Version="$(AkkaVersion)" /> | ||
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" /> | ||
<PackageReference Include="xunit" Version="$(XunitVersion)" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVersion)"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="1.3.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Hyperion\Hyperion.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using Akka.Actor; | ||
using Akka.Configuration; | ||
using Akka.Serialization; | ||
using Xunit; | ||
using Akka.TestKit; | ||
using Akka.TestKit.Xunit2; | ||
using FluentAssertions; | ||
using Xunit.Abstractions; | ||
using AkkaSerializer = Akka.Serialization.Serializer; | ||
|
||
namespace Hyperion.Akka.Integration.Tests | ||
{ | ||
public class IntegrationSpec : TestKit | ||
{ | ||
private static readonly Config Config = ConfigurationFactory.ParseString(@" | ||
akka { | ||
loglevel = WARNING | ||
stdout-loglevel = WARNING | ||
serialize-messages = on | ||
actor { | ||
serializers { | ||
hyperion = ""Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion"" | ||
} | ||
serialization-bindings { | ||
""System.Object"" = hyperion | ||
} | ||
} | ||
} | ||
# use random ports to avoid race conditions with binding contention | ||
akka.remote.dot-netty.tcp.port = 0"); | ||
|
||
private readonly AkkaSerializer _serializer; | ||
|
||
public IntegrationSpec(ITestOutputHelper output) | ||
: base(Config, nameof(IntegrationSpec), output) | ||
{ | ||
_serializer = Sys.Serialization.FindSerializerForType(typeof(object)); | ||
} | ||
|
||
[Fact] | ||
public void Akka_should_load_Hyperion_correctly() | ||
{ | ||
_serializer.Should().BeOfType<HyperionSerializer>(); | ||
} | ||
|
||
[Fact] | ||
public void Akka_HyperionSerializer_should_serialize_properly() | ||
{ | ||
var myObject = new MyPocoClass | ||
{ | ||
Name = "John Doe", | ||
Count = 24 | ||
}; | ||
|
||
var serialized = _serializer.ToBinary(myObject); | ||
var deserialized = _serializer.FromBinary<MyPocoClass>(serialized); | ||
|
||
deserialized.Name.Should().Be("John Doe"); | ||
deserialized.Count.Should().Be(24); | ||
} | ||
|
||
private class MyPocoClass | ||
{ | ||
public string Name { get; set; } | ||
public int Count { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters