}
}
- protected AttributeCollection()
+ protected AttributeCollection() : this(Array.Empty<Attribute>())
{
}
/// </summary>
public DesignerCollection(IList designers)
{
- _designers = designers;
+ _designers = designers ?? new ArrayList();
}
/// <summary>
/// </summary>
public override void SetSavedLicenseKey(Type type, string key)
{
+ if (type == null)
+ {
+ throw new ArgumentNullException(nameof(type));
+ }
+
_savedLicenseKeys[type.AssemblyQualifiedName] = key;
}
}
/// </summary>
public override string ToString()
{
- string str = CommandID.ToString() + " : ";
+ string str = (CommandID?.ToString() ?? "") + " : ";
if ((_status & SUPPORTED) != 0)
{
str += "Supported";
/// </summary>
public DesignerSerializerAttribute(Type serializerType, Type baseSerializerType)
{
+ if (serializerType == null)
+ {
+ throw new ArgumentNullException(nameof(serializerType));
+ }
+ if (baseSerializerType == null)
+ {
+ throw new ArgumentNullException(nameof(baseSerializerType));
+ }
+
SerializerTypeName = serializerType.AssemblyQualifiedName;
SerializerBaseTypeName = baseSerializerType.AssemblyQualifiedName;
}
/// </summary>
public DesignerSerializerAttribute(string serializerTypeName, Type baseSerializerType)
{
+ if (baseSerializerType == null)
+ {
+ throw new ArgumentNullException(nameof(baseSerializerType));
+ }
+
SerializerTypeName = serializerTypeName;
SerializerBaseTypeName = baseSerializerType.AssemblyQualifiedName;
}
{
if (_typeId == null)
{
- string baseType = SerializerBaseTypeName;
+ string baseType = SerializerBaseTypeName ?? string.Empty;
int comma = baseType.IndexOf(',');
if (comma != -1)
{
/// </summary>
public RootDesignerSerializerAttribute(Type serializerType, Type baseSerializerType, bool reloadable)
{
+ if (serializerType == null)
+ {
+ throw new ArgumentNullException(nameof(serializerType));
+ }
+ if (baseSerializerType == null)
+ {
+ throw new ArgumentNullException(nameof(baseSerializerType));
+ }
+
SerializerTypeName = serializerType.AssemblyQualifiedName;
SerializerBaseTypeName = baseSerializerType.AssemblyQualifiedName;
Reloadable = reloadable;
/// </summary>
public RootDesignerSerializerAttribute(string serializerTypeName, Type baseSerializerType, bool reloadable)
{
+ if (baseSerializerType == null)
+ {
+ throw new ArgumentNullException(nameof(baseSerializerType));
+ }
+
SerializerTypeName = serializerTypeName;
SerializerBaseTypeName = baseSerializerType.AssemblyQualifiedName;
Reloadable = reloadable;
{
if (_typeId == null)
{
- string baseType = SerializerBaseTypeName;
+ string baseType = SerializerBaseTypeName ?? string.Empty;
int comma = baseType.IndexOf(',');
if (comma != -1)
{
/// </summary>
public DesignerAttribute(Type designerType)
{
+ if (designerType == null)
+ {
+ throw new ArgumentNullException(nameof(designerType));
+ }
+
DesignerTypeName = designerType.AssemblyQualifiedName;
DesignerBaseTypeName = typeof(IDesigner).FullName;
}
/// </summary>
public DesignerAttribute(string designerTypeName, Type designerBaseType)
{
- DesignerTypeName = designerTypeName ?? throw new ArgumentNullException(nameof(designerTypeName));
+ if (designerTypeName == null)
+ {
+ throw new ArgumentNullException(nameof(designerTypeName));
+ }
+ if (designerBaseType == null)
+ {
+ throw new ArgumentNullException(nameof(designerBaseType));
+ }
+
+ DesignerTypeName = designerTypeName;
DesignerBaseTypeName = designerBaseType.AssemblyQualifiedName;
}
/// </summary>
public DesignerAttribute(Type designerType, Type designerBaseType)
{
+ if (designerType == null)
+ {
+ throw new ArgumentNullException(nameof(designerType));
+ }
+ if (designerBaseType == null)
+ {
+ throw new ArgumentNullException(nameof(designerBaseType));
+ }
+
DesignerTypeName = designerType.AssemblyQualifiedName;
DesignerBaseTypeName = designerBaseType.AssemblyQualifiedName;
}
{
if (_typeId == null)
{
- string baseType = DesignerBaseTypeName;
+ string baseType = DesignerBaseTypeName ?? string.Empty;
int comma = baseType.IndexOf(',');
if (comma != -1)
{
/// </summary>
public EditorAttribute(string typeName, Type baseType)
{
- EditorTypeName = typeName ?? throw new ArgumentNullException(nameof(typeName));
+ if (typeName == null)
+ {
+ throw new ArgumentNullException(nameof(typeName));
+ }
+ if (baseType == null)
+ {
+ throw new ArgumentNullException(nameof(baseType));
+ }
+
+ EditorTypeName = typeName;
EditorBaseTypeName = baseType.AssemblyQualifiedName;
}
/// </summary>
public EditorAttribute(Type type, Type baseType)
{
+ if (type == null)
+ {
+ throw new ArgumentNullException(nameof(type));
+ }
+ if (baseType == null)
+ {
+ throw new ArgumentNullException(nameof(baseType));
+ }
+
EditorTypeName = type.AssemblyQualifiedName;
EditorBaseTypeName = baseType.AssemblyQualifiedName;
}
{
if (_typeId == null)
{
- string baseType = EditorBaseTypeName;
+ string baseType = EditorBaseTypeName ?? string.Empty;
int comma = baseType.IndexOf(',');
if (comma != -1)
{
{
return true;
}
+ if (!(obj is ExtenderProvidedPropertyAttribute other))
+ {
+ return false;
+ }
+
+ if (other.IsDefaultAttribute())
+ {
+ return IsDefaultAttribute();
+ }
- return obj is ExtenderProvidedPropertyAttribute other
- && other.ExtenderProperty.Equals(ExtenderProperty)
+ return other.ExtenderProperty.Equals(ExtenderProperty)
&& other.Provider.Equals(Provider)
&& other.ReceiverType.Equals(ReceiverType);
}
/// </summary>
public InstallerTypeAttribute(Type installerType)
{
+ if (installerType == null)
+ {
+ throw new ArgumentNullException(nameof(installerType));
+ }
+
_typeName = installerType.AssemblyQualifiedName;
}
/// Initializes a new instance of the <see cref='System.ComponentModel.LicenseException'/> class for the
/// specified type.
/// </summary>
- public LicenseException(Type type) : this(type, null, SR.Format(SR.LicExceptionTypeOnly, type.FullName))
+ public LicenseException(Type type) : this(type, null, SR.Format(SR.LicExceptionTypeOnly, type?.FullName))
{
}
/// <summary>
/// Initializes a new instance of the <see cref='System.ComponentModel.LicenseException'/> class for the
/// specified type and instance.
/// </summary>
- public LicenseException(Type type, object instance) : this(type, null, SR.Format(SR.LicExceptionTypeAndInstance, type.FullName, instance.GetType().FullName))
+ public LicenseException(Type type, object instance) : this(type, null, SR.Format(SR.LicExceptionTypeAndInstance, type?.FullName, instance?.GetType().FullName))
{
}
/// <summary>
/// </summary>
public ProvidePropertyAttribute(string propertyName, Type receiverType)
{
+ if (receiverType == null)
+ {
+ throw new ArgumentNullException(nameof(receiverType));
+ }
+
PropertyName = propertyName;
ReceiverTypeName = receiverType.AssemblyQualifiedName;
}
&& other.ReceiverTypeName == ReceiverTypeName;
}
- public override int GetHashCode() => PropertyName.GetHashCode() ^ ReceiverTypeName.GetHashCode();
+ public override int GetHashCode()
+ {
+ return (PropertyName?.GetHashCode() ?? 0) ^ (ReceiverTypeName?.GetHashCode() ?? 0);
+ }
public override object TypeId => GetType().FullName + PropertyName;
}
public RefreshEventArgs(object componentChanged)
{
ComponentChanged = componentChanged;
- TypeChanged = componentChanged.GetType();
+ TypeChanged = componentChanged?.GetType();
}
/// <summary>
/// </summary>
public ToolboxItemAttribute(Type toolboxItemType)
{
+ if (toolboxItemType == null)
+ {
+ throw new ArgumentNullException(nameof(toolboxItemType));
+ }
+
_toolboxItemType = toolboxItemType;
_toolboxItemTypeName = toolboxItemType.AssemblyQualifiedName;
}
public void Ctor_Default()
{
var subAttributeCollection = new SubAttributeCollection();
- Assert.Throws<NullReferenceException>(() => subAttributeCollection.Count);
+ if (!PlatformDetection.IsFullFramework)
+ {
+ Assert.Equal(0, subAttributeCollection.Count);
+ Assert.Empty(subAttributeCollection);
+ }
+ else
+ {
+ Assert.Throws<NullReferenceException>(() => subAttributeCollection.Count);
+ Assert.Throws<NullReferenceException>(() => subAttributeCollection.GetEnumerator());
+ }
}
- [Theory]
- [InlineData(20)]
- [InlineData(1000)]
- [InlineData(1)]
- [InlineData(0)]
- public void Ctor_Attributes(int count)
+ public static IEnumerable<object[]> Ctor_Attributes_TestData()
{
- Attribute[] attributes = GetAttributes().Take(count).ToArray();
- var attributeCollection = new AttributeCollection(attributes);
- Assert.Equal(attributes, attributeCollection.Cast<Attribute>());
+ yield return new object[] { GetAttributes().Take(20).ToArray() };
+ yield return new object[] { GetAttributes().Take(1).ToArray() };
+ yield return new object[] { new Attribute[0] };
+ yield return new object[] { null };
}
- [Fact]
- public void Ctor_NullAttributes_ReturnsEmpty()
+ [Theory]
+ [MemberData(nameof(Ctor_Attributes_TestData))]
+ public void Ctor_Attributes(Attribute[] attributes)
{
- var collection = new AttributeCollection(null);
- Assert.Equal(0, collection.Count);
+ var attributeCollection = new AttributeCollection(attributes);
+ Assert.Equal(attributes?.Length ?? 0, attributeCollection.Count);
+ Assert.Equal(attributes ?? new Attribute[0], attributeCollection.Cast<Attribute>());
}
[Fact]
Assert.Equal(attributeCollection.Cast<Attribute>(), array.Cast<Attribute>().Skip(index));
}
+ [Fact]
+ public void CopyTo_Default_Nop()
+ {
+ var attributeCollection = new SubAttributeCollection();
+ var array = new object[] { 1, 2, 3 };
+ if (!PlatformDetection.IsFullFramework)
+ {
+ attributeCollection.CopyTo(array, 1);
+ }
+ else
+ {
+ Assert.Throws<NullReferenceException>(() => attributeCollection.CopyTo(array, 1));
+ }
+ Assert.Equal(new object[] { 1, 2, 3}, array);
+ }
+
[Theory]
[InlineData(20)]
[InlineData(1000)]
Assert.False(attributeCollection.Contains(new Attribute[] { new ReadOnlyAttribute(true) }));
}
+ [Fact]
+ public void Contains_Default_ReturnsFalse()
+ {
+ var attributeCollection = new SubAttributeCollection();
+ if (!PlatformDetection.IsFullFramework)
+ {
+ Assert.False(attributeCollection.Contains(new ReadOnlyAttribute(true)));
+ Assert.False(attributeCollection.Contains(new Attribute[] { new ReadOnlyAttribute(true) }));
+ }
+ else
+ {
+ Assert.Throws<NullReferenceException>(() => attributeCollection.Contains(new ReadOnlyAttribute(true)));
+ Assert.Throws<NullReferenceException>(() => attributeCollection.Contains(new Attribute[] { new ReadOnlyAttribute(true) }));
+ }
+ }
+
[Theory]
[InlineData(20)]
[InlineData(1000)]
};
var collection = new AttributeCollection(attributes);
-
+
Assert.True(collection.Matches(attributes));
Assert.False(collection.Matches(notInCollection));
}
- private IEnumerable<Attribute> GetAttributes()
+ [Fact]
+ public void Matches_Default_ReturnsFalse()
+ {
+ var attributeCollection = new SubAttributeCollection();
+ if (!PlatformDetection.IsFullFramework)
+ {
+ Assert.False(attributeCollection.Matches(new ReadOnlyAttribute(true)));
+ Assert.False(attributeCollection.Matches(new Attribute[] { new ReadOnlyAttribute(true) }));
+ }
+ else
+ {
+ Assert.Throws<NullReferenceException>(() => attributeCollection.Matches(new ReadOnlyAttribute(true)));
+ Assert.Throws<NullReferenceException>(() => attributeCollection.Matches(new Attribute[] { new ReadOnlyAttribute(true) }));
+ }
+ }
+
+ private static IEnumerable<Attribute> GetAttributes()
{
while (true)
{
{
public static IEnumerable<object[]> Ctor_TestData()
{
+ // [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, ".NET Core fixed a NRE bug.")]
+ if (!PlatformDetection.IsFullFramework)
+ {
+ yield return new object[] { null };
+ }
+
yield return new object[] { new IDesignerHost[] { new TestDesignerHost(), null, new TestDesignerHost() } };
}
[Theory]
- [InlineData(null)]
[MemberData(nameof(Ctor_TestData))]
public void Ctor_DesignersArray(IDesignerHost[] designers)
{
public void Ctor_DesignersIList(IDesignerHost[] designers)
{
var collection = new DesignerCollection((IList)designers);
- Assert.Equal(designers.Length, collection.Count);
- Assert.Equal(designers, collection.Cast<IDesignerHost>());
- }
-
- [Fact]
- public void Ctor_NullDesignersIList_Success()
- {
- var collection = new DesignerCollection((IList)null);
- Assert.Throws<NullReferenceException>(() => collection.Count);
- Assert.Throws<NullReferenceException>(() => collection.GetEnumerator());
- Assert.Throws<NullReferenceException>(() => collection[0]);
+ Assert.Equal(designers?.Length ?? 0, collection.Count);
+ Assert.Equal(designers ?? Enumerable.Empty<IDesignerHost>(), collection.Cast<IDesignerHost>());
}
[Fact]
Assert.Equal(new IDesignerHost[] { null, designers[0], designers[1], null }, destination);
}
+
+ [Fact]
+ [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, ".NET Core fixed a NRE bug.")]
+ public void CopyTo_NullIList_Nop()
+ {
+ ICollection collection = new DesignerCollection((IList)null);
+ var array = new object[] { 1, 2, 3 };
+ collection.CopyTo(array, 1);
+ Assert.Equal(new object[] { 1, 2, 3}, array);
+ }
}
}
public void SetSavedLicenseKey_NullType_ThrowsNullReferenceException()
{
var context = new DesigntimeLicenseContext();
- Assert.Throws<NullReferenceException>(() => context.SetSavedLicenseKey(null, "Key"));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("type", () => context.SetSavedLicenseKey(null, "Key"));
}
}
}
}
[Fact]
- public void ToString_NullCommandId_ThrowsNullReferenceException()
+ public void ToString_NullCommandI_ReturnsExpected()
{
var command = new MenuCommand(new EventHandler(EventHandler), null);
- Assert.Throws<NullReferenceException>(() => command.ToString());
+ if (!PlatformDetection.IsFullFramework)
+ {
+ Assert.Equal(" : Supported|Enabled|Visible", command.ToString());
+ }
+ else
+ {
+ Assert.Throws<NullReferenceException>(() => command.ToString());
+ }
}
[Fact]
}
[Fact]
- public void Ctor_NullSerializerType_ThrowsNullReferenceException()
+ public void Ctor_NullSerializerType_ThrowsArgumentNullException()
{
- Assert.Throws<NullReferenceException>(() => new DesignerSerializerAttribute((Type)null, typeof(int)));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>(() => new DesignerSerializerAttribute((Type)null, typeof(int)));
}
[Fact]
- public void Ctor_NullBaseSerializerType_ThrowsNullReferenceException()
+ public void Ctor_NullBaseSerializerType_ThrowsArgumentNullException()
{
- Assert.Throws<NullReferenceException>(() => new DesignerSerializerAttribute(typeof(int), (Type)null));
- Assert.Throws<NullReferenceException>(() => new DesignerSerializerAttribute("int", (Type)null));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("baseSerializerType", () => new DesignerSerializerAttribute(typeof(int), (Type)null));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("baseSerializerType", () => new DesignerSerializerAttribute("int", (Type)null));
}
[Theory]
public void TypeId_NullBaseSerializerTypeName_ThrowsNullReferenceException()
{
var attribute = new DesignerSerializerAttribute("SerializerType", (string)null);
- Assert.Throws<NullReferenceException>(() => attribute.TypeId);
+ if (!PlatformDetection.IsFullFramework)
+ {
+ Assert.Equal("System.ComponentModel.Design.Serialization.DesignerSerializerAttribute", attribute.TypeId);
+ }
+ else
+ {
+ Assert.Throws<NullReferenceException>(() => attribute.TypeId);
+ }
}
}
}
[Fact]
public void Ctor_NullSerializerType_ThrowsNullReferenceException()
{
- Assert.Throws<NullReferenceException>(() => new RootDesignerSerializerAttribute((Type)null, typeof(int), false));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("serializerType", () => new RootDesignerSerializerAttribute((Type)null, typeof(int), false));
}
[Fact]
public void Ctor_NullBaseSerializerType_ThrowsNullReferenceException()
{
- Assert.Throws<NullReferenceException>(() => new RootDesignerSerializerAttribute(typeof(int), (Type)null, false));
- Assert.Throws<NullReferenceException>(() => new RootDesignerSerializerAttribute("int", (Type)null, false));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("baseSerializerType", () => new RootDesignerSerializerAttribute(typeof(int), (Type)null, false));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("baseSerializerType", () => new RootDesignerSerializerAttribute("int", (Type)null, false));
}
[Theory]
}
[Fact]
- public void TypeId_NullBaseSerializerTypeName_ThrowsNullReferenceException()
+ public void TypeId_NullBaseSerializerTypeName_ReturnsExpected()
{
var attribute = new RootDesignerSerializerAttribute("SerializerType", (string)null, reloadable: true);
- Assert.Throws<NullReferenceException>(() => attribute.TypeId);
+ if (!PlatformDetection.IsFullFramework)
+ {
+ Assert.Equal("System.ComponentModel.Design.Serialization.RootDesignerSerializerAttribute", attribute.TypeId);
+ }
+ else
+ {
+ Assert.Throws<NullReferenceException>(() => attribute.TypeId);
+ }
}
}
#pragma warning restore 0618
}
[Fact]
- public void Ctor_NullDesignerTypeName_ThrowsArgumentNullExceptionException()
+ public void Ctor_NullDesignerTypeName_ThrowsArgumentNullException()
{
AssertExtensions.Throws<ArgumentNullException, NullReferenceException>(() => new DesignerAttribute((string)null));
AssertExtensions.Throws<ArgumentNullException, NullReferenceException>(() => new DesignerAttribute(null, "designerBaseTypeName"));
}
[Fact]
- public void Ctor_NullDesignerType_ThrowsNullReferenceException()
+ public void Ctor_NullDesignerType_ThrowsArgumentNullException()
{
- Assert.Throws<NullReferenceException>(() => new DesignerAttribute((Type)null));
- Assert.Throws<NullReferenceException>(() => new DesignerAttribute((Type)null, typeof(int)));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("designerType", () => new DesignerAttribute((Type)null));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("designerType", () => new DesignerAttribute((Type)null, typeof(int)));
}
[Fact]
- public void Ctor_NullDesignerBaseType_ThrowsNullReferenceException()
+ public void Ctor_NullDesignerBaseType_ThrowsArgumentNullException()
{
- Assert.Throws<NullReferenceException>(() => new DesignerAttribute("designerTypeName", (Type)null));
- Assert.Throws<NullReferenceException>(() => new DesignerAttribute(typeof(int), null));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("designerBaseType", () => new DesignerAttribute("designerTypeName", (Type)null));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("designerBaseType", () => new DesignerAttribute(typeof(int), null));
}
[Theory]
public void TypeId_NullDesignerDesignerTypeName_ThrowsNullReferenceException()
{
var attribute = new DesignerAttribute("DesignerType", (string)null);
- Assert.Throws<NullReferenceException>(() => attribute.TypeId);
+ if (!PlatformDetection.IsFullFramework)
+ {
+ Assert.Equal("System.ComponentModel.DesignerAttribute", attribute.TypeId);
+ }
+ else
+ {
+ Assert.Throws<NullReferenceException>(() => attribute.TypeId);
+ }
}
public static IEnumerable<object[]> Equals_TestData()
}
[Fact]
- public void Ctor_NullEditorTypeName_ThrowsArgumentNullException()
+ public void Ctor_NullTypeName_ThrowsArgumentNullException()
{
- AssertExtensions.Throws<ArgumentNullException, NullReferenceException>(() => new EditorAttribute(null, "baseTypeName"));
- AssertExtensions.Throws<ArgumentNullException, NullReferenceException>(() => new EditorAttribute((string)null, typeof(int)));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("typeName", () => new EditorAttribute(null, "baseTypeName"));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("typeName", () => new EditorAttribute((string)null, typeof(int)));
}
[Fact]
- public void Ctor_NullType_ThrowsNullReferenceException()
+ public void Ctor_NullType_ThrowsArgumentNullException()
{
- Assert.Throws<NullReferenceException>(() => new EditorAttribute((Type)null, typeof(int)));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("type", () => new EditorAttribute((Type)null, typeof(int)));
}
[Fact]
- public void Ctor_NullEditorBaseType_ThrowsNullReferenceException()
+ public void Ctor_NullBaseType_ThrowsArgumentNullException()
{
- Assert.Throws<NullReferenceException>(() => new EditorAttribute("typeName", (Type)null));
- Assert.Throws<NullReferenceException>(() => new EditorAttribute(typeof(int), null));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("baseType", () => new EditorAttribute("typeName", (Type)null));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("baseType", () => new EditorAttribute(typeof(int), null));
}
[Theory]
}
[Fact]
- public void TypeId_NullBaseTypeName_ThrowsNullReferenceException()
+ public void TypeId_NullBaseTypeName_ReturnsExpected()
{
var attribute = new EditorAttribute("Type", (string)null);
- Assert.Throws<NullReferenceException>(() => attribute.TypeId);
+ if (!PlatformDetection.IsFullFramework)
+ {
+ Assert.Equal("System.ComponentModel.EditorAttribute", attribute.TypeId);
+ }
+ else
+ {
+ Assert.Throws<NullReferenceException>(() => attribute.TypeId);
+ }
}
public static IEnumerable<object[]> Equals_TestData()
public void Equals_NullProperties_ThrowsNullReferenceException()
{
var attribute = new ExtenderProvidedPropertyAttribute();
- Assert.Throws<NullReferenceException>(() => attribute.Equals(new ExtenderProvidedPropertyAttribute()));
+ if (!PlatformDetection.IsFullFramework)
+ {
+ Assert.True(attribute.Equals(new ExtenderProvidedPropertyAttribute()));
+ }
+ else
+ {
+ Assert.Throws<NullReferenceException>(() => attribute.Equals(new ExtenderProvidedPropertyAttribute()));
+ }
}
}
}
[Theory]
[InlineData(typeof(int))]
[InlineData(typeof(InstallerTypeAttribute))]
- public void Ctor_InheritanceLevel(Type installerType)
+ public void Ctor_Type(Type installerType)
{
var attribute = new InstallerTypeAttribute(installerType);
Assert.Equal(installerType, attribute.InstallerType);
}
[Fact]
- public void Ctor_NullInstallerType_ThrowsNullReferenceException()
+ public void Ctor_NullInstallerType_ThrowsArgumentNullException()
{
- Assert.Throws<NullReferenceException>(() => new InstallerTypeAttribute((Type)null));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("installerType", () => new InstallerTypeAttribute((Type)null));
}
[Theory]
{
public class LicenseExceptionTests
{
+ public static IEnumerable<object[]> Ctor_Type_TestData()
+ {
+ if (!PlatformDetection.IsFullFramework)
+ {
+ yield return new object[] { null };
+ }
+
+ yield return new object[] { typeof(int) };
+ }
+
[Theory]
- [InlineData(typeof(int))]
+ [MemberData(nameof(Ctor_Type_TestData))]
public void Ctor_Type(Type type)
{
var exception = new LicenseException(type);
Assert.NotEmpty(exception.Message);
}
+ public static IEnumerable<object[]> Ctor_Type_Object_TestData()
+ {
+ if (!PlatformDetection.IsFullFramework)
+ {
+ yield return new object[] { null, null };
+ }
+
+ yield return new object[] { typeof(int), "instance" };
+ }
+
[Theory]
- [InlineData(typeof(int), "instance")]
+ [MemberData(nameof(Ctor_Type_Object_TestData))]
public void Ctor_Type_Object(Type type, object instance)
{
var exception = new LicenseException(type, instance);
}
[Fact]
- public void Ctor_NullType_ThrowsNullReferenceException()
- {
- Assert.Throws<NullReferenceException>(() => new LicenseException(null));
- Assert.Throws<NullReferenceException>(() => new LicenseException(null, new object()));
- }
-
- [Fact]
- public void Ctor_NullInstance_ThrowsNullReferenceException()
- {
- Assert.Throws<NullReferenceException>(() => new LicenseException(typeof(int), null));
- }
-
- [Fact]
public void Ctor_SerializationInfo_StreamingContext()
{
using (var stream = new MemoryStream())
[Fact]
public void Ctor_NullReceiverType_ThrowsNullReferenceException()
{
- Assert.Throws<NullReferenceException>(() => new ProvidePropertyAttribute("propertyName", (Type)null));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("receiverType", () => new ProvidePropertyAttribute("propertyName", (Type)null));
}
public static IEnumerable<object[]> Equals_TestData()
}
[Fact]
- public void GetHashCode_NullPropertyName_ThrowsNullReferenceException()
+ public void GetHashCode_NullPropertyName_ReturnsEqual()
{
var attribute = new ProvidePropertyAttribute(null, "receiverTypeName");
- Assert.Throws<NullReferenceException>(() => attribute.GetHashCode());
+ if (!PlatformDetection.IsFullFramework)
+ {
+ Assert.Equal(attribute.GetHashCode(), attribute.GetHashCode());
+ }
+ else
+ {
+ Assert.Throws<NullReferenceException>(() => attribute.GetHashCode());
+ }
}
[Fact]
- public void GetHashCode_NullReceiverTypeName_ThrowsNullReferenceException()
+ public void GetHashCode_NullReceiverTypeName_ReturnsEqual()
{
var attribute = new ProvidePropertyAttribute("propertyName", (string)null);
- Assert.Throws<NullReferenceException>(() => attribute.GetHashCode());
+
+ if (!PlatformDetection.IsFullFramework)
+ {
+ Assert.Equal(attribute.GetHashCode(), attribute.GetHashCode());
+ }
+ else
+ {
+ Assert.Throws<NullReferenceException>(() => attribute.GetHashCode());
+ }
}
}
}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Collections.Generic;
using Xunit;
namespace System.ComponentModel.Tests
Assert.Same(typeChanged, args.TypeChanged);
}
- [Fact]
- public void Ctor_Object()
+ public static IEnumerable<object[]> Ctor_Object_TestData()
{
- object componentChanged = "componentChanged";
- var args = new RefreshEventArgs(componentChanged);
- Assert.Same(componentChanged, args.ComponentChanged);
- Assert.Equal(typeof(string), args.TypeChanged);
+ if (!PlatformDetection.IsFullFramework)
+ {
+ yield return new object[] { null, null };
+ }
+
+ yield return new object[] { "componentChanged", typeof(string) };
}
- [Fact]
- public void Ctor_NullComponentChanged_ThrowsNullReferenceException()
+ [Theory]
+ [MemberData(nameof(Ctor_Object_TestData))]
+ public void Ctor_Object(object componentChanged, Type expectedTypeChanged)
{
- Assert.Throws<NullReferenceException>(() => new RefreshEventArgs((object)null));
+ var args = new RefreshEventArgs(componentChanged);
+ Assert.Same(componentChanged, args.ComponentChanged);
+ Assert.Equal(expectedTypeChanged, args.TypeChanged);
}
}
}
[Fact]
public void Ctor_NullToolboxItemType_ThrowsNullReferenceException()
{
- Assert.Throws<NullReferenceException>(() => new ToolboxItemAttribute((Type)null));
+ AssertExtensions.Throws<ArgumentNullException, NullReferenceException>("toolboxItemType", () => new ToolboxItemAttribute((Type)null));
}
[Fact]