public void FromRedis_should_return_an_object_of_a_supported_type_with_an_ICollection_of_strings() { RedisMapper.RegisterType <CollectionOfStringsTestType1>(); var subject = new Dictionary <string, RedisValue> { { "StringCollection", $@"{typeof(List<string>).AssemblyQualifiedName}||item1||item2||item3||\|item4" } }; var result = RedisMapper.FromRedisValues <CollectionOfStringsTestType1>(subject); Assert.That(result.StringCollection, Has.Exactly(4).Items); Assert.That( result.StringCollection, Is.EquivalentTo(new[] { "item1", "item2", "item3", "|item4" })); }
public void FromRedis_should_return_an_object_of_a_supported_type_with_an_ICollection_of_Guids() { RedisMapper.RegisterType <CollectionOfGuidTestType1>(); var subject = new Dictionary <string, RedisValue> { { "GuidCollection", $@"{ typeof(List<Guid>).AssemblyQualifiedName }||00000000-0000-0000-0000-000000000000||11c43ee8-b9d3-4e51-b73f-bd9dda66e29c" } }; var result = RedisMapper.FromRedisValues <CollectionOfGuidTestType1>(subject); Assert.That(result.GuidCollection, Has.Exactly(2).Items); Assert.That( result.GuidCollection, Is.EquivalentTo(new[] { Guid.Empty, Guid.Parse("11c43ee8-b9d3-4e51-b73f-bd9dda66e29c") })); }
public void FromRedis_should_return_an_object_of_a_supported_type_without_a_collection() { RedisMapper.RegisterType <TestType1>(); var subject = new Dictionary <string, RedisValue> { { "BoolProperty", true }, { "ByteProperty", (byte)255 }, { "SByteProperty", (sbyte)-128 }, { "ShortProperty", (short)-32768 }, { "UShortProperty", (ushort)65535 }, { "IntProperty", (int)-2147483648 }, { "UIntProperty", (uint)4294967295 }, { "LongProperty", (long)-9223372036854775808 }, { "ULongProperty", ((ulong)18446744073709551615).ToString(CultureInfo.InvariantCulture) }, { "FloatProperty", 2.0f }, { "DoubleProperty", 3.0d }, { "DecimalProperty", 1234.5678m.ToString(CultureInfo.InvariantCulture) }, { "DateTimeProperty", new DateTime(2000, 1, 1, 12, 0, 0).ToString("O") }, { "CharProperty", "a" }, { "StringProperty", "teszt" }, { "GeoPositionProperty", "12.123,45.456" }, { "ByteArrayProperty", new byte[] { 0, 1, 2 } }, { "GuidProperty", Guid.Empty.ToString() }, }; var result = RedisMapper.FromRedisValues <TestType1>(subject); Assert.That(result.BoolProperty, Is.True); Assert.That(result.ByteProperty, Is.EqualTo(255)); Assert.That(result.SByteProperty, Is.EqualTo(-128)); Assert.That(result.ShortProperty, Is.EqualTo(-32768)); Assert.That(result.UShortProperty, Is.EqualTo(65535)); Assert.That(result.IntProperty, Is.EqualTo(-2147483648)); Assert.That(result.UIntProperty, Is.EqualTo(4294967295)); Assert.That(result.LongProperty, Is.EqualTo(-9223372036854775808)); Assert.That(result.ULongProperty, Is.EqualTo(18446744073709551615)); Assert.That(result.FloatProperty, Is.EqualTo(2.0f)); Assert.That(result.DoubleProperty, Is.EqualTo(3.0d)); Assert.That(result.DecimalProperty, Is.EqualTo(1234.5678m)); Assert.That(result.DateTimeProperty, Is.EqualTo(new DateTime(2000, 1, 1, 12, 0, 0))); Assert.That(result.CharProperty, Is.EqualTo('a')); Assert.That(result.StringProperty, Is.EqualTo("teszt")); Assert.That(result.GeoPositionProperty, Is.EqualTo(new GeoPosition(12.123, 45.456))); Assert.That( result.ByteArrayProperty, Is.EquivalentTo(new[] { 0, 1, 2 })); Assert.That(result.GuidProperty, Is.EqualTo(Guid.Empty)); }