Пример #1
0
    public void Empty_Returns_Empty_List(string input)
    {
        // Arrange
        var handler = new ImmutableListJsonbTypeHandler <Foo>();

        // Act
        var result = handler.Parse(input);

        // Assert
        Assert.Empty(result);
    }
Пример #2
0
    public void Incorrect_Json_Returns_Empty_List()
    {
        // Arrange
        var          handler = new ImmutableListJsonbTypeHandler <Foo>();
        const string?json    = /*lang=json,strict*/ "{\"foo\":\"bar\"}";

        // Act
        var result = handler.Parse(json);

        // Assert
        Assert.Empty(result);
    }
Пример #3
0
    public void Invalid_Json_Returns_Empty_List()
    {
        // Arrange
        var handler = new ImmutableListJsonbTypeHandler <Foo>();
        var json    = Rnd.Str;

        // Act
        var result = handler.Parse(json);

        // Assert
        Assert.Empty(result);
    }
Пример #4
0
    public void Correct_Json_Returns_List()
    {
        // Arrange
        var handler = new ImmutableListJsonbTypeHandler <Foo>();
        var itemA   = new Foo(Rnd.Str);
        var itemB   = new Foo(Rnd.Str);
        var itemC   = new Foo(Rnd.Str);
        var itemD   = new Foo(Rnd.Str);
        var json    = $"[\"{itemB}\",\"{itemD}\",\"{itemA}\",\"{itemC}\"]";

        // Act
        var result = handler.Parse(json);

        // Assert
        Assert.Collection(result,
                          b => Assert.Equal(itemB, b),
                          d => Assert.Equal(itemD, d),
                          a => Assert.Equal(itemA, a),
                          c => Assert.Equal(itemC, c)
                          );
    }