public void PropertyAsParameterInfoTests_ContainsPropertyCustomAttributes() { // Arrange var propertyInfo = GetProperty(typeof(ArgumentList), nameof(ArgumentList.WithTestAttribute)); var parameterInfo = new PropertyAsParameterInfo(propertyInfo); // Act & Assert Assert.Single(parameterInfo.GetCustomAttributes(typeof(TestAttribute))); }
public void PropertyAsParameterInfoTests_WithConstructorArgument_FallbackToPropertyCustomAttributes() { // Arrange var propertyInfo = GetProperty(typeof(ArgumentList), nameof(ArgumentList.WithTestAttribute)); var parameter = GetParameter(nameof(ArgumentList.DefaultMethod), nameof(ArgumentList.NoAttribute)); var parameterInfo = new PropertyAsParameterInfo(propertyInfo, parameter); // Act & Assert Assert.Single(parameterInfo.GetCustomAttributes(typeof(TestAttribute))); }
public void PropertyAsParameterInfoTests_WithConstructorArgument_MergePropertyAndParameterCustomAttributes() { // Arrange 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.GetCustomAttributes(true); // Assert Assert.Single( attributes, a => typeof(TestAttribute).IsAssignableFrom(a.GetType())); Assert.Single( attributes, a => typeof(SampleAttribute).IsAssignableFrom(a.GetType())); }