コード例 #1
0
        public void FixedValueCodecs_AppropriateData_Decodes(string json, string type, object expected)
        {
            object result = null;

            switch (type)
            {
            case "bool":
                result = Bool.DecodeString(json).Match(x => (object)x, e => (object)e);
                break;

            case "decimal":
                expected = Convert.ToDecimal(expected);
                result   = Decimal.DecodeString(json).Match(x => (object)x, e => (object)e);
                break;

            case "guid":
                expected = new Guid((string)expected);
                result   = Guid.DecodeString(json).Match(x => (object)x, e => (object)e);
                break;

            case "int":
                result = Int.DecodeString(json).Match(x => (object)x, e => (object)e);
                break;

            case "string":
                result = String.DecodeString(json).Match(x => (object)x, e => (object)e);
                break;
            }
            Assert.Equal(expected, result);
        }
コード例 #2
0
 public void Decimal_InapropriateData_DoesNotDecode(string input)
 {
     Assert.Equal("Expected a decimal value", Decimal.DecodeString(input).Match(x => "", x => x.Errors.First().Message));
 }