Esempio n. 1
0
    public void Can_jsv_serialize_TimeOnly()
    {
        var time = new TimeOnly(13, 13, 13);
        var json = time.ToJsv();

        Assert.That(json, Is.EqualTo("PT13H13M13S"));

        var fromJson = json.FromJsv <TimeOnly>();

        Assert.That(fromJson, Is.EqualTo(time));

        var dto = new TimeOnlyDto {
            Time = time
        };

        json = dto.ToJsv();
        Assert.That(json, Is.EqualTo("{Time:PT13H13M13S}"));
        var fromJsonDto = json.FromJsv <TimeOnlyDto>();

        Assert.That(fromJsonDto, Is.EqualTo(dto));

        var nullableDto = new NullableTimeOnlyDto {
            Time = time
        };

        json = nullableDto.ToJsv();
        Assert.That(json, Is.EqualTo("{Time:PT13H13M13S}"));
        var fromJsonNullableDto = json.FromJsv <NullableTimeOnlyDto>();

        Assert.That(fromJsonNullableDto, Is.EqualTo(nullableDto));
    }