Пример #1
0
    public void PropertyAsParameterInfoTests_WithConstructorArgument_MergePropertyAndParameterCustomAttributesData()
    {
        // Arrange & Act
        var propertyInfo  = GetProperty(typeof(ArgumentList), nameof(ArgumentList.WithTestAttribute));
        var parameter     = GetParameter(nameof(ArgumentList.DefaultMethod), nameof(ArgumentList.WithSampleAttribute));
        var parameterInfo = new PropertyAsParameterInfo(propertyInfo, parameter);

        // Act
        var attributes = parameterInfo.GetCustomAttributesData();

        // Assert
        Assert.Single(
            parameterInfo.GetCustomAttributesData(),
            a => typeof(TestAttribute).IsAssignableFrom(a.AttributeType));
        Assert.Single(
            parameterInfo.GetCustomAttributesData(),
            a => typeof(SampleAttribute).IsAssignableFrom(a.AttributeType));
    }
Пример #2
0
    public void PropertyAsParameterInfoTests_ContainsPropertyCustomAttributesData()
    {
        // Arrange
        var propertyInfo  = GetProperty(typeof(ArgumentList), nameof(ArgumentList.WithTestAttribute));
        var parameterInfo = new PropertyAsParameterInfo(propertyInfo);

        // Act
        var attributes = parameterInfo.GetCustomAttributesData();

        // Assert
        Assert.Single(
            attributes,
            a => typeof(TestAttribute).IsAssignableFrom(a.AttributeType));
    }