diff --git a/GroBuf.Tests/GroBuf.Tests.csproj b/GroBuf.Tests/GroBuf.Tests.csproj index d2aabb7..29705ec 100644 --- a/GroBuf.Tests/GroBuf.Tests.csproj +++ b/GroBuf.Tests/GroBuf.Tests.csproj @@ -6,12 +6,17 @@ - + + - + + + + + diff --git a/GroBuf.Tests/TestNull.cs b/GroBuf.Tests/TestNull.cs index 87c2bd6..676c355 100644 --- a/GroBuf.Tests/TestNull.cs +++ b/GroBuf.Tests/TestNull.cs @@ -1,4 +1,4 @@ -using System; +using System; using GroBuf.DataMembersExtracters; @@ -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 diff --git a/GroBuf.Tests/TestReproForIssue17.cs b/GroBuf.Tests/TestReproForIssue17.cs new file mode 100644 index 0000000..3532792 --- /dev/null +++ b/GroBuf.Tests/TestReproForIssue17.cs @@ -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>(bytes); + + deserializedDict.Should().BeEquivalentTo(dict); + } + } +} \ No newline at end of file