Esempio n. 1
0
        static KV1BinaryNodeType GetNodeType(KVValueType type)
        {
            switch (type)
            {
            case KVValueType.FloatingPoint:
                return(KV1BinaryNodeType.Float32);

            case KVValueType.Int32:
                return(KV1BinaryNodeType.Int32);

            case KVValueType.Pointer:
                return(KV1BinaryNodeType.Pointer);

            case KVValueType.String:
                return(KV1BinaryNodeType.String);

            case KVValueType.UInt64:
                return(KV1BinaryNodeType.UInt64);

            case KVValueType.Int64:
                return(KV1BinaryNodeType.Int64);

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, "Unsupported value type.");
            }
        }
Esempio n. 2
0
        public KVObjectValue(TObject value, KVValueType valueType)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            this.value = value;
            ValueType  = valueType;
        }
 static KV1BinaryNodeType GetNodeType(KVValueType type)
 {
     return(type switch
     {
         KVValueType.FloatingPoint => KV1BinaryNodeType.Float32,
         KVValueType.Int32 => KV1BinaryNodeType.Int32,
         KVValueType.Pointer => KV1BinaryNodeType.Pointer,
         KVValueType.String => KV1BinaryNodeType.String,
         KVValueType.UInt64 => KV1BinaryNodeType.UInt64,
         KVValueType.Int64 => KV1BinaryNodeType.Int64,
         _ => throw new ArgumentOutOfRangeException(nameof(type), type, "Unhandled value type."),
     });
Esempio n. 4
0
        public void HasValueOfType <TExpected>(KVValueType expectedType, TypeCode expectedTypeCode, string key, TExpected expectedValue)
        {
            var actualValue = data[key];

            Assert.That(actualValue, Is.Not.Null);
            Assert.That(actualValue.ValueType, Is.EqualTo(expectedType), nameof(KVValueType));
            Assert.That(actualValue.GetTypeCode(), Is.EqualTo(expectedTypeCode), nameof(TypeCode));

            var typedActualValue = Convert.ChangeType(actualValue, typeof(TExpected));

            Assert.That(typedActualValue, Is.EqualTo(expectedValue));
        }