Пример #1
0
        public void ToRedis_should_be_able_to_handle_array_of_strings()
        {
            RedisMapper.RegisterType <CollectionOfStringsTestType1>();
            Assert.That(
                RedisMapper.TypesWithRegisteredProperties[typeof(CollectionOfStringsTestType1)],
                Has.One.Items);

            var subject = new CollectionOfStringsTestType1
            {
                StringCollection = new[]
                {
                    "item1",
                    "item2",
                    "item3",
                    @"|item4"
                }
            };

            var result = RedisMapper.MapToRedisValues(subject);

            Assert.That(
                result["StringCollection"],
                Is.EqualTo((RedisValue) $@"{
                        typeof(string[]).AssemblyQualifiedName
                    }||item1||item2||item3||\|item4"));
        }
Пример #2
0
        public void ToRedis_should_be_able_to_handle_an_empty_array_of_strings()
        {
            RedisMapper.RegisterType <CollectionOfStringsTestType1>();
            Assert.That(
                RedisMapper.TypesWithRegisteredProperties[typeof(CollectionOfStringsTestType1)],
                Has.One.Items);

            var subject = new CollectionOfStringsTestType1
            {
                StringCollection = new string[0]
            };

            var result = RedisMapper.MapToRedisValues(subject);

            Assert.That(
                result["StringCollection"],
                Is.EqualTo((RedisValue)typeof(string[]).AssemblyQualifiedName));
        }