Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 public void Bool_InapropriateData_DoesNotDecode(string input)
 {
     Assert.Equal("Expected a boolean value", Bool.DecodeString(input).Match(x => "", x => x.Errors.First().Message));
 }