-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
953a8e4
commit 9fc49e9
Showing
3 changed files
with
54 additions
and
11 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
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,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); | ||
} | ||
} | ||
} |