Skip to content

Commit

Permalink
Bump NUnit from 3.14.0 to 4.0.0 in /samples (#269)
Browse files Browse the repository at this point in the history
* Bump NUnit from 3.14.0 to 4.0.0 in /samples

Bumps [NUnit](https://github.com/nunit/nunit) from 3.14.0 to 4.0.0.
- [Release notes](https://github.com/nunit/nunit/releases)
- [Changelog](https://github.com/nunit/nunit/blob/master/CHANGES.md)
- [Commits](nunit/nunit@v3.14.0...v4.0.0)

---
updated-dependencies:
- dependency-name: NUnit
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Implement Fluent Validation

* Add NUnit.Analyzers

* Fix TapGesture Test

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brandon Minnick <[email protected]>
  • Loading branch information
dependabot[bot] and TheCodeTraveler authored Nov 27, 2023
1 parent 7ac435c commit d58fbc0
Show file tree
Hide file tree
Showing 24 changed files with 569 additions and 591 deletions.
5 changes: 3 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
CS1592: Badly formed XML in included comments file
CS1598: XML parser could not be loaded. The XML documentation file will not be generated.
CS1658: Identifier expected; 'true' is a keyword
CS1734: XML comment has a paramref tag, but there is no parameter by that name -->
<WarningsAsErrors>nullable,CS0419,CS1570,CS1571,CS1572,CS1573,CS1574,CS1580,CS1581,CS1584,CS1589,CS1590,CS1592,CS1598,CS1658,CS1734</WarningsAsErrors>
CS1734: XML comment has a paramref tag, but there is no parameter by that name
NUnit2007: Warning NUnit2007 : The actual value should not be a constant - perhaps the actual value and the expected value have switched places -->
<WarningsAsErrors>nullable,CS0419,CS1570,CS1571,CS1572,CS1573,CS1574,CS1580,CS1581,CS1584,CS1589,CS1590,CS1592,CS1598,CS1658,CS1734,NUnit2007</WarningsAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ public void LayoutBoundsAllDouble() => TestPropertiesSet(
public void ClearLayoutFlags()
{
var label = new Label().ClearLayoutFlags();
Assert.AreEqual(AbsoluteLayoutFlags.None, label.GetPropertyIfSet(AbsoluteLayout.LayoutFlagsProperty, (AbsoluteLayoutFlags)(-1)));
Assert.That(label.GetPropertyIfSet(AbsoluteLayout.LayoutFlagsProperty, (AbsoluteLayoutFlags)(-1)), Is.EqualTo(AbsoluteLayoutFlags.None));
}

// Cannot use TestPropertiesSet() because ClearLayoutFlags sets AbsoluteLayout.LayoutFlagsProperty to its default
[Test]
public void ClearLayoutFlagsAfterSettingLayoutFlags()
{
var label = new Label().LayoutFlags(AbsoluteLayoutFlags.XProportional).ClearLayoutFlags();
Assert.AreEqual(AbsoluteLayoutFlags.None, label.GetPropertyIfSet(AbsoluteLayout.LayoutFlagsProperty, AbsoluteLayoutFlags.XProportional));
Assert.That(label.GetPropertyIfSet(AbsoluteLayout.LayoutFlagsProperty, AbsoluteLayoutFlags.XProportional), Is.EqualTo(AbsoluteLayoutFlags.None));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -690,42 +690,42 @@ public void BindCommandWithPositionalParameters()
[Test]
public void SupportDerivedElements()
{
Assert.IsInstanceOf<DerivedFromLabel>(
new DerivedFromLabel()
.Bind(nameof(viewModel.Text))
.Bind(
nameof(viewModel.Text),
convert: (string? text) => $"'{text}'")
.Bind(
nameof(viewModel.Text),
convert: (string? text, int? repeat) =>
{
ArgumentNullException.ThrowIfNull(text);
ArgumentNullException.ThrowIfNull(repeat);

return string.Concat(Enumerable.Repeat($"'{text.Trim('\'')}'", repeat.Value));
})
.Bind(
DerivedFromLabel.TextColorProperty,
nameof(viewModel.TextColor))
.Bind(
DerivedFromLabel.BackgroundColorProperty,
nameof(viewModel.IsRed),
convert: (bool? isRed) => isRed.HasValue && isRed.Value ? Colors.Black : Colors.Transparent)
.Bind(
Label.TextColorProperty,
nameof(viewModel.IsRed),
convert: (bool? isRed, float? alpha) =>
{
ArgumentNullException.ThrowIfNull(alpha);

return (isRed.HasValue && isRed.Value ? Colors.Red : Colors.Green).MultiplyAlpha(alpha.Value);
})
.Invoke(l => l.Text = nameof(SupportDerivedElements))
.Assign(out DerivedFromLabel assignDerivedFromLabel));

Assert.IsInstanceOf<DerivedFromTextCell>(new DerivedFromTextCell().BindCommand(nameof(viewModel.Command)));
Assert.IsInstanceOf<DerivedFromLabel>(assignDerivedFromLabel);
Assert.That(new DerivedFromLabel()
.Bind(nameof(viewModel.Text))
.Bind(
nameof(viewModel.Text),
convert: (string? text) => $"'{text}'")
.Bind(
nameof(viewModel.Text),
convert: (string? text, int? repeat) =>
{
ArgumentNullException.ThrowIfNull(text);
ArgumentNullException.ThrowIfNull(repeat);

return string.Concat(Enumerable.Repeat($"'{text.Trim('\'')}'", repeat.Value));
})
.Bind(
DerivedFromLabel.TextColorProperty,
nameof(viewModel.TextColor))
.Bind(
DerivedFromLabel.BackgroundColorProperty,
nameof(viewModel.IsRed),
convert: (bool? isRed) => isRed.HasValue && isRed.Value ? Colors.Black : Colors.Transparent)
.Bind(
Label.TextColorProperty,
nameof(viewModel.IsRed),
convert: (bool? isRed, float? alpha) =>
{
ArgumentNullException.ThrowIfNull(alpha);

return (isRed.HasValue && isRed.Value ? Colors.Red : Colors.Green).MultiplyAlpha(alpha.Value);
})
.Invoke(l => l.Text = nameof(SupportDerivedElements))
.Assign(out DerivedFromLabel assignDerivedFromLabel),
Is.InstanceOf<DerivedFromLabel>());

Assert.That(new DerivedFromTextCell().BindCommand(nameof(viewModel.Command)), Is.InstanceOf<DerivedFromTextCell>());
Assert.That(assignDerivedFromLabel, Is.InstanceOf<DerivedFromLabel>());
}

[TestCase(AppTheme.Light)]
Expand All @@ -738,7 +738,7 @@ public void AppThemeColorBindingCorrectlySetsPropertyToChangeBasedOnApplications
ApplicationTestHelpers.PerformAppThemeBasedTest(
appTheme,
() => new Label().AppThemeColorBinding(Label.TextColorProperty, Colors.Purple, Colors.Orange),
(label) => Assert.AreEqual(expectedColor, label.TextColor));
(label) => Assert.That(label.TextColor, Is.EqualTo(expectedColor)));
}

[TestCase(AppTheme.Light)]
Expand All @@ -754,7 +754,7 @@ public void AppThemeBindingCorrectlySetsPropertyToChangeBasedOnApplicationsAppTh
ApplicationTestHelpers.PerformAppThemeBasedTest(
appTheme,
() => new Label().AppThemeBinding(Label.TextProperty, light, dark),
(label) => Assert.AreEqual(expectedText, label.Text));
(label) => Assert.That(label.Text, Is.EqualTo(expectedText)));
}

class ViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ internal static void AssertTypedBindingExists<TBindable, TBindingContext, TSourc

Assert.That(binding.ConverterParameter, Is.EqualTo(expectedConverterParameter));

Assert.IsInstanceOf<TBindingContext>(expectedSource);
Assert.That(expectedSource, Is.InstanceOf<TBindingContext>());
Assert.That(binding.StringFormat, Is.EqualTo(expectedStringFormat));
Assert.That(binding.TargetNullValue, Is.EqualTo(expectedTargetNullValue));
Assert.That(binding.FallbackValue, Is.EqualTo(expectedFallbackValue));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit" Version="4.0.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0" PrivateAssets="all" />
<PackageReference Include="NUnit.Analyzers" Version="3.7.0" PrivateAssets="all" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="CommunityToolkit.Maui" Version="7.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,6 @@ public void GetDefaultBindablePropertiesForDerivedType()
public void GetDefaultBindablePropertiesForMauiDerivedType()
=> Assert.That(DefaultBindableProperties.GetDefaultProperty<MenuFlyoutItem>(), Is.Not.Null);

[Test]
public void GetDefaultBindableCommandPropertiesForBuiltInType()
=> Assert.That(DefaultBindableProperties.GetCommandAndCommandParameterProperty<Button>(), Is.Not.Null);

[Test]
public void GetDefaultBindableCommandPropertiesForDerivedType()
=> Assert.That(DefaultBindableProperties.GetCommandAndCommandParameterProperty<DerivedFromButton>(), Is.Not.Null);

[Test]
public void GetDefaultBindableCommandPropertiesForMauiDerivedType()
=> Assert.That(DefaultBindableProperties.GetCommandAndCommandParameterProperty<MenuFlyoutItem>(), Is.Not.Null);

[Test]
public void GetDefaultBindableCommandPropertiesForUnsupportedType()
=> Assert.Throws<ArgumentException>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ public void NotConverterTest()
{
var c = NotConverter.Instance;
c = NotConverter.Instance; // 2nd time to test instance reuse
Assert.IsTrue((bool?)c.Convert(false, null, null, null));
Assert.IsFalse((bool?)c.Convert(true, null, null, null));
Assert.IsTrue((bool?)c.ConvertBack(false, null, null, null));
Assert.IsFalse((bool?)c.ConvertBack(true, null, null, null));
Assert.That((bool?)c.Convert(false, null, null, null), Is.True);
Assert.That((bool?)c.Convert(true, null, null, null), Is.False);
Assert.That((bool?)c.ConvertBack(false, null, null, null), Is.True);
Assert.That((bool?)c.ConvertBack(true, null, null, null), Is.False);
}
}
Loading

0 comments on commit d58fbc0

Please sign in to comment.