Ejemplo n.º 1
0
    public void Serialize()
    {
        // arrange
        var type            = new AnyType();
        var objectValueNode = new ObjectValueNode(
            new ObjectFieldNode(
                AnyType.TypeNameField,
                "test"
                ),
            new ObjectFieldNode(
                "foo",
                "bar"
                )
            );
        var representation = new Representation
        {
            TypeName = "test",
            Data     = objectValueNode
        };

        // act
        object?serialized = type.Serialize(representation);

        // assert
        Assert.Equal(objectValueNode, serialized);
    }
Ejemplo n.º 2
0
    public void Serialize_Invalid_Format()
    {
        // arrange
        var type = new AnyType();

        // act
        void Action() => type.Serialize(1);

        // assert
        Assert.Throws <SerializationException>(Action);
    }