Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ObjectExtensionsTests to Include Derived Types #136

Merged
merged 4 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
<!--CS1572: XML comment has a param tag for '[parameter]', but there is no parameter by that name -->
<!--CS1573: Parameter has no matching param tag in the XML comment -->
<!--CS1574: XML comment has cref attribute that could not be resolved-->
<!--CS1710: XML comment has a duplicate typeparam tag-->
<!--CS1734: XML comment has a paramref tag, but there is no parameter by that name-->
<WarningsAsErrors>nullable,CS1570,CS1571,CS1572,CS1573,CS1574,CS1734</WarningsAsErrors>
<WarningsAsErrors>nullable,CS1570,CS1571,CS1572,CS1573,CS1574,CS1710,CS1734</WarningsAsErrors>
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ public void AssignLabel()
Assert.That(ReferenceEquals(createdLabel, assignedLabel));
}

[Test]
public void AssignCustomLabel()
{
var createdLabel = new CustomLabel().Assign(out Label assignedLabel).Assign(out CustomLabel assignedCustomLabel);
Assert.That(ReferenceEquals(createdLabel, assignedLabel));
Assert.That(ReferenceEquals(assignedCustomLabel, assignedLabel));
}

[Test]
public void AssignString()
{
Expand All @@ -39,11 +47,30 @@ public void Invoke()
Assert.That(createdLabel.Text, Is.EqualTo(text));
}

[Test]
public void InvokeCustomEntry()
{
const string text = nameof(Invoke);

var createdLabel = new CustomEntry().Invoke(l => l.Text = text);
Assert.That(createdLabel.Text, Is.EqualTo(text));
}

[Test]
public void InvokeNullThrowsArgumentNullException()
{
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
Assert.Throws<ArgumentNullException>(() => new Label().Invoke(null));
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
}

class CustomLabel : Label
{

}

class CustomEntry : Entry
{

}
}
4 changes: 2 additions & 2 deletions src/CommunityToolkit.Maui.Markup/ObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public static class ObjectExtensions
{
/// <summary>
/// Assign <typeparam name="TAssignable"/> to a variable
/// Assign <typeparamref name="TAssignable"/> to a variable
/// </summary>
/// <typeparam name="TAssignable"></typeparam>
/// <typeparam name="TVariable"></typeparam>
Expand All @@ -21,7 +21,7 @@ public static class ObjectExtensions
}

/// <summary>
/// Perform an action on <typeparam name="TAssignable"/>
/// Perform an action on <typeparamref name="TAssignable"/>
/// </summary>
/// <typeparam name="TAssignable"></typeparam>
/// <param name="assignable"></param>
Expand Down