Exemple #1
0
        public void Read_null()
        {
            // Arrange
            var json = "";

            var textReader    = new StringReader(json);
            var jsonReader    = new JsonTextReader(textReader);
            var objectType    = (Type)null;
            var existingValue = (object)null;
            var serializer    = new JsonSerializer();

            var converter = new IntegerBooleanConverter();

            // Act
            jsonReader.Read();
            var result = converter.ReadJson(jsonReader, objectType, existingValue, serializer);

            // Assert
            result.ShouldBeNull();
        }
Exemple #2
0
        public void Read_false()
        {
            // Arrange
            var json = "\"Anything other than the numeral 1 should yield false\"";

            var textReader    = new StringReader(json);
            var jsonReader    = new JsonTextReader(textReader);
            var objectType    = (Type)null;
            var existingValue = (object)null;
            var serializer    = new JsonSerializer();

            var converter = new IntegerBooleanConverter();

            // Act
            jsonReader.Read();
            var result = converter.ReadJson(jsonReader, objectType, existingValue, serializer);

            // Assert
            result.ShouldBeOfType <bool>();
            ((bool)result).ShouldBeFalse();
        }