public void ValidatesCollections()
    {
        var model = new TestObjectWithList()
        {
            Test = new List <TestItem>()
            {
                new TestItem(),
                new TestItem()
                {
                    Test = "valid"
                },
                new TestItem()
            }
        };

        var result = DataAnnotationsValidator.Validate(model);

        Assert.False(result.IsValid);
        Assert.Collection(result.Errors,
                          e =>
        {
            Assert.Equal("Test[0].Test", e.Key);
            Assert.Collection(e.Value, er => Assert.Equal("The Test field is required.", er));
        },
                          e =>
        {
            Assert.Equal("Test[2].Test", e.Key);
            Assert.Collection(e.Value, er => Assert.Equal("The Test field is required.", er));
        });
    }
    public void ValidatesNullCollections()
    {
        var model = new TestObjectWithList
        {
            Test = null
        };

        var result = DataAnnotationsValidator.Validate(model);

        Assert.True(result.IsValid);
    }