Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
halgab committed Jan 25, 2024
1 parent 4973582 commit ec1931a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable
using System.Collections.Generic;
using Xunit;

Expand All @@ -13,24 +12,24 @@ public class ContentWrapperAttributeTests
[Theory]
[InlineData(null)]
[InlineData(typeof(int))]
public void Ctor_Type(Type contentWrapper)
public void Ctor_Type(Type? contentWrapper)
{
var attribute = new ContentWrapperAttribute(contentWrapper);
var attribute = new ContentWrapperAttribute(contentWrapper!);
Assert.Equal(contentWrapper, attribute.ContentWrapper);
}

public static IEnumerable<object[]> Equals_TestData()
{
var attribute = new ContentWrapperAttribute(typeof(int));
yield return new object[] { attribute, attribute, true };
yield return new object[] { attribute, new ContentWrapperAttribute(typeof(int)), true };
yield return new object[] { attribute, new ContentWrapperAttribute(typeof(string)), false };
yield return new object[] { attribute, new ContentWrapperAttribute(null), false };
yield return new object[] { new ContentWrapperAttribute(null), new ContentWrapperAttribute(null), true };
yield return new object[] { new ContentWrapperAttribute(null), new ContentWrapperAttribute(typeof(int)), false };

yield return new object[] { attribute, new object(), false };
yield return new object[] { attribute, null, false };
yield return new object?[] { attribute, attribute, true };
yield return new object?[] { attribute, new ContentWrapperAttribute(typeof(int)), true };
yield return new object?[] { attribute, new ContentWrapperAttribute(typeof(string)), false };
yield return new object?[] { attribute, new ContentWrapperAttribute(null!), false };
yield return new object?[] { new ContentWrapperAttribute(null!), new ContentWrapperAttribute(null!), true };
yield return new object?[] { new ContentWrapperAttribute(null!), new ContentWrapperAttribute(typeof(int)), false };

yield return new object?[] { attribute, new object(), false };
yield return new object?[] { attribute, null, false };
}

[Theory]
Expand All @@ -50,7 +49,7 @@ public void GetHashCode_Invoke_ReturnsExpected()
[Fact]
public void GetHashCode_InvokeNullContentWrapper_ReturnsZero()
{
var attribute = new ContentWrapperAttribute(null);
var attribute = new ContentWrapperAttribute(null!);
Assert.Equal(0, attribute.GetHashCode());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public void Ctor_Type_Type(Type loaderType, Type contentType)
[Fact]
public void Ctor_NullLoaderType_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("loaderType", () => new XamlDeferLoadAttribute(null, typeof(int)));
Assert.Throws<ArgumentNullException>("loaderType", () => new XamlDeferLoadAttribute(null!, typeof(int)));
}

[Fact]
public void Ctor_NullContentType_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("contentType", () => new XamlDeferLoadAttribute(typeof(int), null));
Assert.Throws<ArgumentNullException>("contentType", () => new XamlDeferLoadAttribute(typeof(int), null!));
}

[Theory]
Expand All @@ -48,13 +48,13 @@ public void Ctor_String_String(string loaderType, string contentType)
[Fact]
public void Ctor_NullLoaderTypeName_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("loaderType", () => new XamlDeferLoadAttribute(null, "contentType"));
Assert.Throws<ArgumentNullException>("loaderType", () => new XamlDeferLoadAttribute(null!, "contentType"));
}

[Fact]
public void Ctor_NullContentTypeName_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("contentType", () => new XamlDeferLoadAttribute("loaderType", null));
Assert.Throws<ArgumentNullException>("contentType", () => new XamlDeferLoadAttribute("loaderType", null!));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public void Ctor_String_String(string oldNamespace, string newNamespace)
[Fact]
public void Ctor_NullOldNamespace_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("oldNamespace", () => new XmlnsCompatibleWithAttribute(null, "newNamespace"));
Assert.Throws<ArgumentNullException>("oldNamespace", () => new XmlnsCompatibleWithAttribute(null!, "newNamespace"));
}

[Fact]
public void Ctor_NullNewNamespace_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("newNamespace", () => new XmlnsCompatibleWithAttribute("oldNamespace", null));
Assert.Throws<ArgumentNullException>("newNamespace", () => new XmlnsCompatibleWithAttribute("oldNamespace", null!));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public void Ctor_String_String(string xmlNamespace, string clrNamespace)
[Fact]
public void Ctor_NullXmlNamespace_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("xmlNamespace", () => new XmlnsDefinitionAttribute(null, "clrNamespace"));
Assert.Throws<ArgumentNullException>("xmlNamespace", () => new XmlnsDefinitionAttribute(null!, "clrNamespace"));
}

[Fact]
public void Ctor_NullClrNamespace_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("clrNamespace", () => new XmlnsDefinitionAttribute("xmlNamespace", null));
Assert.Throws<ArgumentNullException>("clrNamespace", () => new XmlnsDefinitionAttribute("xmlNamespace", null!));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public void Ctor_String_String(string xmlNamespace, string prefix)
[Fact]
public void Ctor_NullXmlNamespace_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("xmlNamespace", () => new XmlnsPrefixAttribute(null, "prefix"));
Assert.Throws<ArgumentNullException>("xmlNamespace", () => new XmlnsPrefixAttribute(null!, "prefix"));
}

[Fact]
public void Ctor_NullPrefix_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("prefix", () => new XmlnsPrefixAttribute("xmlNamespace", null));
Assert.Throws<ArgumentNullException>("prefix", () => new XmlnsPrefixAttribute("xmlNamespace", null!));
}
}

0 comments on commit ec1931a

Please sign in to comment.