Skip to content

Commit

Permalink
add repro for issue #17
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKostousov committed Apr 15, 2019
1 parent 953a8e4 commit 9fc49e9
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 11 deletions.
9 changes: 7 additions & 2 deletions GroBuf.Tests/GroBuf.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="FluentAssertions" Version="5.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="protobuf-net" Version="2.4.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net45'">
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GroBuf\GroBuf.csproj" />
</ItemGroup>
Expand Down
10 changes: 1 addition & 9 deletions GroBuf.Tests/TestNull.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

using GroBuf.DataMembersExtracters;

Expand Down Expand Up @@ -41,14 +41,6 @@ public void Test()
Console.WriteLine(serializer.Deserialize(typeof(long), arr3));
}

[Test]
public void Test2()
{
string prev = @"AUABAAD7+4dqyAWRww4aAAAANAA2ADAANwAxADEANwA4ADgANAA1ADQANQCXKqz0ofYgEw4MAAAAMQAyADMANAA1ADYAFI0lnUuxneQOIgAAAC0EQARBBE4EFiEgAFQESwROBEwEQARRBFIERQQWIU4EQgRH7QmXijQ1ZQ4GAAAAUABDAEUAXhnc9MHO7eQNAAAEAAAAAACAiwgAAAAAAArEJGM3c/EEDgQAAAAxADgApgAewED9ehAOAAAAALFSl1huRAAoDhQAAAAwBFMEVwRKBEgEIABCBFEERQRMBMiPwB3tzcafDgAAAABuqp+2NkzVrQ4AAAAARiPpxDURBAcNAAADAAAAAAD4KgAAAAAAAIp4qF30h5M6DgwAAAA0ADQALAAwADAAMAAS37VDXHzi1g4AAAAAtZyIcmn4UY8OAAAAAA==";
string curr = @"AUABAAD7+4dqyAWRww4aAAAANAA2ADAANwAxADEANwA4ADgANAA1ADQANQCXKqz0ofYgEw4MAAAAMQAyADMANAA1ADYAFI0lnUuxneQOIgAAAC0EQARBBE4EFiEgAFQESwROBEwEQARRBFIERQQWIU4EQgRH7QmXijQ1ZQ4GAAAAUABDAEUAXhnc9MHO7eQNAAACAAAAAADgFQAAAAAAAArEJGM3c/EEDgQAAAAxADgApgAewED9ehAOAAAAALFSl1huRAAoDhQAAAAwBFMEVwRKBEgEIABCBFEERQRMBMiPwB3tzcafDgAAAABuqp+2NkzVrQ4AAAAARiPpxDURBAcNAAADAAAAAAD4KgAAAAAAAIp4qF30h5M6DgwAAAA0ADQALAAwADAAMAAS37VDXHzi1g4AAAAAtZyIcmn4UY8OAAAAAA==";
Console.WriteLine(DebugViewBuilder.DebugView(Convert.FromBase64String(curr)));
}

private Serializer serializer;

public class A
Expand Down
46 changes: 46 additions & 0 deletions GroBuf.Tests/TestReproForIssue17.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Collections.Generic;

using FluentAssertions;

using GroBuf.DataMembersExtracters;

using NUnit.Framework;

namespace GroBuf.Tests
{
public class TestReproForIssue17
{
[Test]
public void AllFieldsExtractor_Supports_ValueTuple_As_DictionaryKey()
{
TestValueTupleAsDictionaryKey(new Serializer(new AllFieldsExtractor()));
}

[Test]
[Explicit("repro for https://github.com/skbkontur/GroBuf/issues/17")]
public void AllPropertiesExtractor_DoesNotSupport_ValueTuple_As_DictionaryKey()
{
TestValueTupleAsDictionaryKey(new Serializer(new AllPropertiesExtractor()));
}

private static void TestValueTupleAsDictionaryKey(Serializer serializer)
{
var key1 = ("k11", "k12");
var key2 = ("k21", "k22");

Assert.That(key1, Is.Not.EqualTo(key2));
Assert.That(key1.GetHashCode(), Is.Not.EqualTo(key2.GetHashCode()));

var dict = new Dictionary<(string, string), string>
{
{key1, "v1"},
{key2, "v2"}
};

var bytes = serializer.Serialize(dict);
var deserializedDict = serializer.Deserialize<Dictionary<(string, string), string>>(bytes);

deserializedDict.Should().BeEquivalentTo(dict);
}
}
}

0 comments on commit 9fc49e9

Please sign in to comment.