public void ParseLiteral_Should_Pass_When_NullValueNode(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act // assert Assert.Null(type.ParseLiteral(NullValueNode.Default)); }
public void ParseLiteral_Should_Throw_When_NotObjectValueNode(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act // assert Assert.Throws <InvalidOperationException>(() => type.ParseLiteral(new ListValueNode())); }
public void IsInstanceOfType_Should_Pass_When_GeometryOfType(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act // assert Assert.True(type.IsInstanceOfType(_geometry)); }
public void IsInstanceOfType_Should_Fail_When_NoGeometry(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act // assert Assert.False(type.IsInstanceOfType("foo")); }
public void IsInstanceOfType_Should_Pass_When_NullValueNode(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act // assert Assert.True(type.IsInstanceOfType(NullValueNode.Default)); }
public void IsInstanceOfType_Should_Pass_When_ObjectValueNode(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act // assert Assert.True(type.IsInstanceOfType(new ObjectValueNode())); }
public void IsInstanceOfType_Should_Throw_When_Null(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act // assert Assert.Throws <ArgumentNullException>(() => type.IsInstanceOfType(null !)); }
public void ParseResult_Should_Throw_When_InvalidType(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act // assert Assert.Throws <SerializationException>(() => type.ParseResult("")); }
public void ParseValue_Should_Pass_When_NullValue(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act // assert Assert.Equal(NullValueNode.Default, type.ParseValue(null)); }
public void Serialize_Should_Pass_When_SerializeNullValue(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act // assert Assert.Null(type.Serialize(null)); }
public void Serialize_Should_Throw_When_InvalidObjectShouldThrow(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act // assert Assert.Throws <SerializationException>(() => type.Serialize("")); }
public void Deserialize_Should_Throw_When_InvalidType(string typeName) { // arrange var inputParser = new InputParser(new DefaultTypeConverter()); INamedInputType type = CreateInputType(typeName); // act // assert Assert.Throws <SerializationException>(() => inputParser.ParseResult("", type)); }
public void ParseValue_Should_Pass_When_NullValue(string typeName) { // arrange var inputFormatter = new InputFormatter(); INamedInputType type = CreateInputType(typeName); // act // assert Assert.Equal(NullValueNode.Default, inputFormatter.FormatValue(null, type)); }
public void ParseLiteral_Should_Pass_When_NullValueNode(string typeName) { // arrange var inputParser = new InputParser(new DefaultTypeConverter()); INamedInputType type = CreateInputType(typeName); // act // assert Assert.Null(inputParser.ParseLiteral(NullValueNode.Default, type)); }
public void Deserialize_Should_Pass_When_SerializeNullValue(string typeName) { // arrange var inputParser = new InputParser(new DefaultTypeConverter()); INamedInputType type = CreateInputType(typeName); // act // assert Assert.Null(inputParser.ParseResult(null, type)); }
public void ParseValue_Should_Throw_When_InvalidType(string typeName) { // arrange var inputFormatter = new InputFormatter(); INamedInputType type = CreateInputType(typeName); // act // assert Assert.Throws <SerializationException>(() => inputFormatter.FormatValue("", type)); }
public void ParseLiteral_Should_Throw_When_NotObjectValueNode(string typeName) { // arrange var inputParser = new InputParser(new DefaultTypeConverter()); INamedInputType type = CreateInputType(typeName); // act // assert Assert.Throws <SerializationException>( () => inputParser.ParseLiteral(new ListValueNode(), type)); }
public void IsInstanceOfType_Should_Fail_When_DifferentGeoJsonObject(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act // assert Assert.False( type.IsInstanceOfType( GeometryFactory.Default.CreateGeometryCollection(new[] { new Point(1, 2) }))); }
public void ParseLiteral_Should_Throw_When_NoCoordinates(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); var typeField = new ObjectFieldNode(WellKnownFields.TypeFieldName, _geometryType); var crsField = new ObjectFieldNode(WellKnownFields.CrsFieldName, 0); var valueNode = new ObjectValueNode(typeField, crsField); // act Assert.Throws <SerializationException>(() => type.ParseLiteral(valueNode)); }
private void VisitLeaf(INamedInputType type, object obj, Action <object> setValue) { if (type is IHasRuntimeType hasClrType) { Type currentType = obj.GetType(); var normalized = currentType == hasClrType.RuntimeType ? obj : _converter.Convert(currentType, hasClrType.RuntimeType, obj); setValue(normalized); } }
public void Serialize_Should_Pass_When_SerializeGeometry(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act object?result = type.Serialize(_geometry); // assert result.MatchSnapshot(); }
public void Deserialize_Should_Pass_When_SerializeGeometry(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act object?result = type.Deserialize(_geometry); // assert Assert.Equal(result, _geometry); }
public void ParseValue_Should_Pass_When_Value(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); // act IValueNode literal = type.ParseValue(_geometry); // assert literal.ToString().MatchSnapshot(); }
public void Serialize_Should_Pass_When_Dictionary(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); var dictionary = new Dictionary <string, object>(); // act object?result = type.Serialize(dictionary); // assert Assert.Equal(dictionary, result); }
public void Deserialize_Should_Pass_When_PassedSerializedResult(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); object? serialized = type.Serialize(_geometry); // act object?result = type.Deserialize(serialized); // assert Assert.True(Assert.IsAssignableFrom <Geometry>(result).Equals(_geometry)); }
public void ParseResult_Should_Pass_When_Serialized(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); object? serialized = type.Serialize(_geometry); // act IValueNode literal = type.ParseResult(serialized); // assert literal.ToString().MatchSnapshot(); }
public void ParseValue_Should_Pass_When_Value(string typeName) { // arrange var inputFormatter = new InputFormatter(); INamedInputType type = CreateInputType(typeName); // act IValueNode literal = inputFormatter.FormatValue(_geometry, type); // assert literal.ToString().MatchSnapshot(); }
public void Deserialize_Should_Pass_When_SerializeGeometry(string typeName) { // arrange var inputParser = new InputParser(new DefaultTypeConverter()); INamedInputType type = CreateInputType(typeName); // act var result = inputParser.ParseResult(_geometry, type); // assert Assert.Equal(result, _geometry); }
private void VisitLeaf( INamedInputType type, object obj, Action <object> setValue, ISet <object> processed) { if (type is IHasClrType hasClrType) { Type currentType = obj.GetType(); object normalized = currentType == hasClrType.ClrType ? obj : _converter.Convert(currentType, hasClrType.ClrType, obj); setValue(obj); } }
public void Deserialize_Should_When_CoordinatesAreMissing(string typeName) { // arrange INamedInputType type = CreateInputType(typeName); var serialized = new Dictionary <string, object> { { WellKnownFields.TypeFieldName, _geometryType }, { WellKnownFields.CrsFieldName, new IntValueNode(0) } }; // act // assert Assert.Throws <SerializationException>(() => type.Deserialize(serialized)); }