Implement NUnit2045
This commit is contained in:
Родитель
d58fbc04e5
Коммит
2c4a27e0b8
|
@ -28,8 +28,9 @@
|
|||
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
|
||||
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>
|
||||
NUnit2007: Warning NUnit2007 : The actual value should not be a constant - perhaps the actual value and the expected value have switched places
|
||||
NUnit2045: Hosting Asserts inside an Assert.Multiple allows detecting more than one failure-->
|
||||
<WarningsAsErrors>nullable,CS0419,CS1570,CS1571,CS1572,CS1573,CS1574,CS1580,CS1581,CS1584,CS1589,CS1590,CS1592,CS1598,CS1658,CS1734,NUnit2007,NUnit2045</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -690,42 +690,45 @@ namespace CommunityToolkit.Maui.Markup.UnitTests
|
|||
[Test]
|
||||
public void SupportDerivedElements()
|
||||
{
|
||||
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);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
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 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>());
|
||||
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>());
|
||||
Assert.That(new DerivedFromTextCell().BindCommand(nameof(viewModel.Command)), Is.InstanceOf<DerivedFromTextCell>());
|
||||
Assert.That(assignDerivedFromLabel, Is.InstanceOf<DerivedFromLabel>());
|
||||
});
|
||||
}
|
||||
|
||||
[TestCase(AppTheme.Light)]
|
||||
|
|
|
@ -83,18 +83,21 @@ static class BindingHelpers
|
|||
TParam? expectedConverterParameter = default) where TBindable : BindableObject
|
||||
{
|
||||
var binding = GetTypedBinding(bindable, targetProperty) ?? throw new NullReferenceException();
|
||||
Assert.That(binding, Is.Not.Null);
|
||||
|
||||
Assert.That(binding.Mode, Is.EqualTo(expectedBindingMode));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(binding, Is.Not.Null);
|
||||
Assert.That(binding.Mode, Is.EqualTo(expectedBindingMode));
|
||||
|
||||
Assert.That(binding.Converter?.ToString(), Is.EqualTo(expectedConverter?.ToString()));
|
||||
Assert.That(binding.Converter?.ToString(), Is.EqualTo(expectedConverter?.ToString()));
|
||||
|
||||
Assert.That(binding.ConverterParameter, Is.EqualTo(expectedConverterParameter));
|
||||
Assert.That(binding.ConverterParameter, Is.EqualTo(expectedConverterParameter));
|
||||
|
||||
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));
|
||||
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));
|
||||
});
|
||||
}
|
||||
|
||||
internal static void AssertBindingExists<TDest, TParam>(
|
||||
|
@ -112,9 +115,13 @@ static class BindingHelpers
|
|||
Action<IValueConverter>? assertConvert = null)
|
||||
{
|
||||
var binding = GetBinding(bindable, targetProperty) ?? throw new NullReferenceException();
|
||||
Assert.That(binding, Is.Not.Null);
|
||||
Assert.That(binding.Path, Is.EqualTo(path));
|
||||
Assert.That(binding.Mode, Is.EqualTo(mode));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(binding, Is.Not.Null);
|
||||
Assert.That(binding.Path, Is.EqualTo(path));
|
||||
Assert.That(binding.Mode, Is.EqualTo(mode));
|
||||
});
|
||||
|
||||
if (assertConverterInstanceIsAnyNotNull)
|
||||
{
|
||||
|
@ -125,11 +132,14 @@ static class BindingHelpers
|
|||
Assert.That(binding.Converter, Is.EqualTo(converter));
|
||||
}
|
||||
|
||||
Assert.That(binding.ConverterParameter, Is.EqualTo(converterParameter));
|
||||
Assert.That(binding.StringFormat, Is.EqualTo(stringFormat));
|
||||
Assert.That(binding.Source, Is.EqualTo(source));
|
||||
Assert.That(binding.TargetNullValue, Is.EqualTo(targetNullValue));
|
||||
Assert.That(binding.FallbackValue, Is.EqualTo(fallbackValue));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(binding.ConverterParameter, Is.EqualTo(converterParameter));
|
||||
Assert.That(binding.StringFormat, Is.EqualTo(stringFormat));
|
||||
Assert.That(binding.Source, Is.EqualTo(source));
|
||||
Assert.That(binding.TargetNullValue, Is.EqualTo(targetNullValue));
|
||||
Assert.That(binding.FallbackValue, Is.EqualTo(fallbackValue));
|
||||
});
|
||||
|
||||
assertConvert?.Invoke(binding.Converter);
|
||||
}
|
||||
|
@ -163,9 +173,13 @@ static class BindingHelpers
|
|||
Action<IMultiValueConverter>? assertConvert = null)
|
||||
{
|
||||
var binding = GetMultiBinding(bindable, targetProperty) ?? throw new NullReferenceException();
|
||||
Assert.That(binding, Is.Not.Null);
|
||||
Assert.That(binding.Bindings.SequenceEqual(bindings), Is.True);
|
||||
Assert.That(binding.Mode, Is.EqualTo(mode));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(binding, Is.Not.Null);
|
||||
Assert.That(binding.Bindings.SequenceEqual(bindings), Is.True);
|
||||
Assert.That(binding.Mode, Is.EqualTo(mode));
|
||||
});
|
||||
|
||||
if (assertConverterInstanceIsAnyNotNull)
|
||||
{
|
||||
|
@ -176,10 +190,13 @@ static class BindingHelpers
|
|||
Assert.That(binding.Converter, Is.EqualTo(converter));
|
||||
}
|
||||
|
||||
Assert.That(binding.ConverterParameter, Is.EqualTo(converterParameter));
|
||||
Assert.That(binding.StringFormat, Is.EqualTo(stringFormat));
|
||||
Assert.That(binding.TargetNullValue, Is.EqualTo(targetNullValue));
|
||||
Assert.That(binding.FallbackValue, Is.EqualTo(fallbackValue));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(binding.ConverterParameter, Is.EqualTo(converterParameter));
|
||||
Assert.That(binding.StringFormat, Is.EqualTo(stringFormat));
|
||||
Assert.That(binding.TargetNullValue, Is.EqualTo(targetNullValue));
|
||||
Assert.That(binding.FallbackValue, Is.EqualTo(fallbackValue));
|
||||
});
|
||||
|
||||
assertConvert?.Invoke(binding.Converter);
|
||||
}
|
||||
|
@ -217,8 +234,11 @@ static class BindingHelpers
|
|||
|
||||
internal static IValueConverter AssertConvert<TValue, TConvertedValue>(this IValueConverter converter, TValue value, object? parameter, TConvertedValue expectedConvertedValue, bool twoWay = false, bool backOnly = false, CultureInfo? culture = null)
|
||||
{
|
||||
Assert.That(converter.Convert(value, typeof(object), parameter, culture ?? CultureInfo.InvariantCulture), Is.EqualTo(backOnly ? default : expectedConvertedValue));
|
||||
Assert.That(converter.ConvertBack(expectedConvertedValue, typeof(object), parameter, culture ?? CultureInfo.InvariantCulture), Is.EqualTo(twoWay || backOnly ? value : default(TValue)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(converter.Convert(value, typeof(object), parameter, culture ?? CultureInfo.InvariantCulture), Is.EqualTo(backOnly ? default : expectedConvertedValue));
|
||||
Assert.That(converter.ConvertBack(expectedConvertedValue, typeof(object), parameter, culture ?? CultureInfo.InvariantCulture), Is.EqualTo(twoWay || backOnly ? value : default(TValue)));
|
||||
});
|
||||
return converter;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,14 +21,20 @@ public class DynamicResourceHandlerTests
|
|||
{
|
||||
var label = new Label { Resources = new ResourceDictionary { { "TextKey", "TextValue" }, { "ColorKey", Colors.Green } } };
|
||||
|
||||
Assert.That(label.Text, Is.EqualTo(Label.TextProperty.DefaultValue));
|
||||
Assert.That(label.TextColor, Is.EqualTo(Label.TextColorProperty.DefaultValue));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(label.Text, Is.EqualTo(Label.TextProperty.DefaultValue));
|
||||
Assert.That(label.TextColor, Is.EqualTo(Label.TextColorProperty.DefaultValue));
|
||||
});
|
||||
|
||||
label.DynamicResources((Label.TextProperty, "TextKey"),
|
||||
(Label.TextColorProperty, "ColorKey"));
|
||||
|
||||
Assert.That(label.Text, Is.EqualTo("TextValue"));
|
||||
Assert.That(label.TextColor, Is.EqualTo(Colors.Green));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(label.Text, Is.EqualTo("TextValue"));
|
||||
Assert.That(label.TextColor, Is.EqualTo(Colors.Green));
|
||||
});
|
||||
|
||||
return label;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,11 @@ class ElementExtensionsTests : BaseMarkupTestFixture<Label>
|
|||
label.Resources["TextKey"] = "ChangedTextValue";
|
||||
label.Resources["ColorKey"] = Colors.Green;
|
||||
|
||||
Assert.That(label.Text, Is.EqualTo("TextValue"));
|
||||
Assert.That(label.TextColor, Is.EqualTo(Colors.Green));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(label.Text, Is.EqualTo("TextValue"));
|
||||
Assert.That(label.TextColor, Is.EqualTo(Colors.Green));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -41,9 +44,12 @@ class ElementExtensionsTests : BaseMarkupTestFixture<Label>
|
|||
NullEffect effect1 = new NullEffect(), effect2 = new NullEffect();
|
||||
Bindable.Effects(effect1, effect2);
|
||||
|
||||
Assert.That(Bindable.Effects.Count, Is.EqualTo(2));
|
||||
Assert.That(Bindable.Effects.Contains(effect1));
|
||||
Assert.That(Bindable.Effects.Contains(effect2));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(Bindable.Effects.Count, Is.EqualTo(2));
|
||||
Assert.That(Bindable.Effects.Contains(effect1));
|
||||
Assert.That(Bindable.Effects.Contains(effect2));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -86,14 +92,20 @@ class ElementExtensionsTests : BaseMarkupTestFixture<Label>
|
|||
{
|
||||
var label = new Label { Resources = new ResourceDictionary { { "TextKey", "TextValue" }, { "ColorKey", Colors.Green } } };
|
||||
|
||||
Assert.That(label.Text, Is.EqualTo(Label.TextProperty.DefaultValue));
|
||||
Assert.That(label.TextColor, Is.EqualTo(Label.TextColorProperty.DefaultValue));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(label.Text, Is.EqualTo(Label.TextProperty.DefaultValue));
|
||||
Assert.That(label.TextColor, Is.EqualTo(Label.TextColorProperty.DefaultValue));
|
||||
});
|
||||
|
||||
label.DynamicResources((Label.TextProperty, "TextKey"),
|
||||
(Label.TextColorProperty, "ColorKey"));
|
||||
|
||||
Assert.That(label.Text, Is.EqualTo("TextValue"));
|
||||
Assert.That(label.TextColor, Is.EqualTo(Colors.Green));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(label.Text, Is.EqualTo("TextValue"));
|
||||
Assert.That(label.TextColor, Is.EqualTo(Colors.Green));
|
||||
});
|
||||
|
||||
return label;
|
||||
}
|
||||
|
|
|
@ -39,13 +39,21 @@ class FuncConverterTests : BaseMarkupTestFixture
|
|||
.AssertConvert(new object[] { 'a', 2 }, true, "aaa", twoWay: true, culture: expectedCulture)
|
||||
.AssertConvert(new object[] { 'b', 4 }, false, "bbbb", twoWay: true, culture: expectedCulture);
|
||||
|
||||
Assert.That(convertCulture, Is.EqualTo(expectedCulture));
|
||||
Assert.That(convertBackCulture, Is.EqualTo(expectedCulture));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(convertCulture, Is.EqualTo(expectedCulture));
|
||||
Assert.That(convertBackCulture, Is.EqualTo(expectedCulture));
|
||||
|
||||
Assert.That(converter.Convert(new object[] { 'a', 2 }, null, null, CultureInfo.InvariantCulture), Is.EqualTo("aa"));
|
||||
});
|
||||
|
||||
Assert.That(converter.Convert(new object[] { 'a', 2 }, null, null, CultureInfo.InvariantCulture), Is.EqualTo("aa"));
|
||||
var backValues = converter.ConvertBack(null, null, null, CultureInfo.InvariantCulture);
|
||||
Assert.That((char)backValues[0], Is.EqualTo('\0'));
|
||||
Assert.That((int)backValues[1], Is.EqualTo(0));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That((char)backValues[0], Is.EqualTo('\0'));
|
||||
Assert.That((int)backValues[1], Is.EqualTo(0));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -76,8 +84,12 @@ class FuncConverterTests : BaseMarkupTestFixture
|
|||
|
||||
Assert.That(converter.Convert(new object[] { 'a', 2 }, null, null, CultureInfo.InvariantCulture), Is.EqualTo("aa"));
|
||||
var backValues = converter.ConvertBack(null, null, null, CultureInfo.InvariantCulture);
|
||||
Assert.That((char)backValues[0], Is.EqualTo('\0'));
|
||||
Assert.That((int)backValues[1], Is.EqualTo(0));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That((char)backValues[0], Is.EqualTo('\0'));
|
||||
Assert.That((int)backValues[1], Is.EqualTo(0));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -102,9 +114,14 @@ class FuncConverterTests : BaseMarkupTestFixture
|
|||
.AssertConvert(new object[] { 'b', 4 }, false, "bbbb", twoWay: true);
|
||||
|
||||
Assert.That(converter.Convert(new object[] { 'a', 2 }, null, null, CultureInfo.InvariantCulture), Is.EqualTo("aa"));
|
||||
|
||||
var backValues = converter.ConvertBack(null, null, null, CultureInfo.InvariantCulture);
|
||||
Assert.That((char)backValues[0], Is.EqualTo('\0'));
|
||||
Assert.That((int)backValues[1], Is.EqualTo(0));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That((char)backValues[0], Is.EqualTo('\0'));
|
||||
Assert.That((int)backValues[1], Is.EqualTo(0));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -127,11 +144,14 @@ class FuncConverterTests : BaseMarkupTestFixture
|
|||
.AssertConvert(true, 0.5f, Colors.Red.MultiplyAlpha(0.5f), twoWay: true, culture: expectedCulture)
|
||||
.AssertConvert(false, 0.2f, Colors.Green.MultiplyAlpha(0.2f), twoWay: true, culture: expectedCulture);
|
||||
|
||||
Assert.That(convertCulture, Is.EqualTo(expectedCulture));
|
||||
Assert.That(convertBackCulture, Is.EqualTo(expectedCulture));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(convertCulture, Is.EqualTo(expectedCulture));
|
||||
Assert.That(convertBackCulture, Is.EqualTo(expectedCulture));
|
||||
|
||||
Assert.That(converter.Convert(null, typeof(object), null, CultureInfo.InvariantCulture), Is.EqualTo(Colors.Green.MultiplyAlpha(default)));
|
||||
Assert.That(converter.ConvertBack(null, typeof(object), null, CultureInfo.InvariantCulture), Is.EqualTo(default(bool)));
|
||||
Assert.That(converter.Convert(null, typeof(object), null, CultureInfo.InvariantCulture), Is.EqualTo(Colors.Green.MultiplyAlpha(default)));
|
||||
Assert.That(converter.ConvertBack(null, typeof(object), null, CultureInfo.InvariantCulture), Is.EqualTo(default(bool)));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -143,8 +163,11 @@ class FuncConverterTests : BaseMarkupTestFixture
|
|||
.AssertConvert(true, 0.5f, Colors.Red.MultiplyAlpha(0.5f), twoWay: true)
|
||||
.AssertConvert(false, 0.2f, Colors.Green.MultiplyAlpha(0.2f), twoWay: true);
|
||||
|
||||
Assert.That(converter.Convert(null, typeof(object), null, CultureInfo.InvariantCulture), Is.EqualTo(Colors.Green.MultiplyAlpha(default)));
|
||||
Assert.That(converter.ConvertBack(null, typeof(object), null, CultureInfo.InvariantCulture), Is.EqualTo(default(bool)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(converter.Convert(null, typeof(object), null, CultureInfo.InvariantCulture), Is.EqualTo(Colors.Green.MultiplyAlpha(default)));
|
||||
Assert.That(converter.ConvertBack(null, typeof(object), null, CultureInfo.InvariantCulture), Is.EqualTo(default(bool)));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -156,8 +179,11 @@ class FuncConverterTests : BaseMarkupTestFixture
|
|||
.AssertConvert(true, Colors.Red, twoWay: true)
|
||||
.AssertConvert(false, Colors.Green, twoWay: true);
|
||||
|
||||
Assert.That(converter.Convert(null, typeof(object), null, CultureInfo.InvariantCulture), Is.EqualTo(Colors.Green));
|
||||
Assert.That(converter.ConvertBack(null, typeof(object), null, CultureInfo.InvariantCulture), Is.EqualTo(default(bool)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(converter.Convert(null, typeof(object), null, CultureInfo.InvariantCulture), Is.EqualTo(Colors.Green));
|
||||
Assert.That(converter.ConvertBack(null, typeof(object), null, CultureInfo.InvariantCulture), Is.EqualTo(default(bool)));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -312,9 +338,13 @@ class FuncConverterTests : BaseMarkupTestFixture
|
|||
{
|
||||
var c = NotConverter.Instance;
|
||||
c = NotConverter.Instance; // 2nd time to test instance reuse
|
||||
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);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -32,9 +32,13 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
|||
|
||||
gestureElement.BindClickGesture(nameof(ViewModel.SetGuidCommand), commandSource, nameof(ViewModel.Id), parameterSource, numberOfClicks);
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
||||
});
|
||||
|
||||
BindingHelpers.AssertBindingExists((ClickGestureRecognizer)gestureElement.GestureRecognizers[0], ClickGestureRecognizer.CommandProperty, nameof(ViewModel.SetGuidCommand), source: commandSource);
|
||||
BindingHelpers.AssertBindingExists((ClickGestureRecognizer)gestureElement.GestureRecognizers[0], ClickGestureRecognizer.CommandParameterProperty, nameof(ViewModel.Id), source: parameterSource);
|
||||
}
|
||||
|
@ -62,9 +66,12 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
|||
|
||||
gestureElement.BindTapGesture(nameof(ViewModel.SetGuidCommand), commandSource, nameof(ViewModel.Id), parameterSource, numberOfTaps);
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||
Assert.That(((TapGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||
Assert.That(((TapGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
||||
});
|
||||
BindingHelpers.AssertBindingExists((TapGestureRecognizer)gestureElement.GestureRecognizers[0], TapGestureRecognizer.CommandProperty, nameof(ViewModel.SetGuidCommand), source: commandSource);
|
||||
BindingHelpers.AssertBindingExists((TapGestureRecognizer)gestureElement.GestureRecognizers[0], TapGestureRecognizer.CommandParameterProperty, nameof(ViewModel.Id), source: parameterSource);
|
||||
}
|
||||
|
@ -81,10 +88,13 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
|||
gestureElement.ClickGesture(() => clicks++, numberOfClicks);
|
||||
((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).SendClicked(null, ButtonsMask.Primary);
|
||||
|
||||
Assert.That(clicks, Is.GreaterThan(0));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(clicks, Is.GreaterThan(0));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -98,10 +108,13 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
|||
gestureElement.TapGesture(() => taps++, numberOfTaps);
|
||||
((TapGestureRecognizer)gestureElement.GestureRecognizers[0]).SendTapped(gestureElement);
|
||||
|
||||
Assert.That(taps, Is.GreaterThan(0));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||
Assert.That(((TapGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(taps, Is.GreaterThan(0));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||
Assert.That(((TapGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -128,10 +141,14 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
|||
|
||||
gestureElement.BindSwipeGesture(nameof(ViewModel.SetGuidCommand), commandSource, nameof(ViewModel.Id), parameterSource, direction, threshold);
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
||||
});
|
||||
|
||||
BindingHelpers.AssertBindingExists((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0], SwipeGestureRecognizer.CommandProperty, nameof(ViewModel.SetGuidCommand), source: commandSource);
|
||||
BindingHelpers.AssertBindingExists((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0], SwipeGestureRecognizer.CommandParameterProperty, nameof(ViewModel.Id), source: parameterSource);
|
||||
}
|
||||
|
@ -147,10 +164,13 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
|||
gestureElement.PanGesture(OnPan, touchPoints);
|
||||
((IPanGestureController)gestureElement.GestureRecognizers[0]).SendPan(null, 1, 2, 1);
|
||||
|
||||
Assert.That(panCount, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<PanGestureRecognizer>());
|
||||
Assert.That(((PanGestureRecognizer)gestureElement.GestureRecognizers[0]).TouchPoints, Is.EqualTo(touchPoints));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(panCount, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<PanGestureRecognizer>());
|
||||
Assert.That(((PanGestureRecognizer)gestureElement.GestureRecognizers[0]).TouchPoints, Is.EqualTo(touchPoints));
|
||||
});
|
||||
|
||||
void OnPan(object? sender, PanUpdatedEventArgs e) => panCount++;
|
||||
}
|
||||
|
@ -165,9 +185,12 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
|||
gestureElement.PinchGesture(OnPinch);
|
||||
((IPinchGestureController)gestureElement.GestureRecognizers[0]).SendPinch(null, 2, new Microsoft.Maui.Graphics.Point());
|
||||
|
||||
Assert.That(pinchCount, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(pinchCount));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<PinchGestureRecognizer>());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(pinchCount, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(pinchCount));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<PinchGestureRecognizer>());
|
||||
});
|
||||
|
||||
void OnPinch(object? sender, PinchGestureUpdatedEventArgs e) => pinchCount++;
|
||||
}
|
||||
|
@ -184,11 +207,14 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
|||
gestureElement.SwipeGesture(OnSwipe, direction, threshold);
|
||||
((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).SendSwiped(null, direction);
|
||||
|
||||
Assert.That(swipeCount, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(swipeCount, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
||||
});
|
||||
|
||||
void OnSwipe(object? sender, SwipedEventArgs e) => swipeCount++;
|
||||
}
|
||||
|
@ -201,9 +227,12 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
|||
gestureElement.PanGesture();
|
||||
gestureElement.SwipeGesture();
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(2));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<PanGestureRecognizer>());
|
||||
Assert.That(gestureElement.GestureRecognizers[1], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(2));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<PanGestureRecognizer>());
|
||||
Assert.That(gestureElement.GestureRecognizers[1], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -227,8 +256,12 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
|||
|
||||
gestureElement.BindClickGesture(static (ViewModel vm) => vm.SetGuidCommand);
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
});
|
||||
|
||||
BindingHelpers.AssertTypedBindingExists((ClickGestureRecognizer)gestureElement.GestureRecognizers[0], ClickGestureRecognizer.CommandProperty, BindingMode.Default, gestureElement.BindingContext);
|
||||
}
|
||||
|
||||
|
@ -251,8 +284,12 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
|||
},
|
||||
mode: BindingMode.OneTime);
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
});
|
||||
|
||||
BindingHelpers.AssertTypedBindingExists((ClickGestureRecognizer)gestureElement.GestureRecognizers[0], ClickGestureRecognizer.CommandProperty, BindingMode.OneTime, gestureElement.BindingContext);
|
||||
}
|
||||
|
||||
|
@ -275,9 +312,13 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
|||
parameterGetter: static (ViewModel vm) => vm.Id,
|
||||
numberOfClicksRequired: numberOfClicks);
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
||||
});
|
||||
|
||||
BindingHelpers.AssertTypedBindingExists((ClickGestureRecognizer)gestureElement.GestureRecognizers[0], ClickGestureRecognizer.CommandProperty, BindingMode.OneTime, gestureElement.BindingContext);
|
||||
BindingHelpers.AssertTypedBindingExists((ClickGestureRecognizer)gestureElement.GestureRecognizers[0], ClickGestureRecognizer.CommandParameterProperty, BindingMode.Default, gestureElement.BindingContext);
|
||||
}
|
||||
|
@ -310,9 +351,13 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
|||
},
|
||||
numberOfClicksRequired: numberOfClicks);
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
||||
});
|
||||
|
||||
BindingHelpers.AssertTypedBindingExists((ClickGestureRecognizer)gestureElement.GestureRecognizers[0], ClickGestureRecognizer.CommandProperty, BindingMode.OneTime, gestureElement.BindingContext);
|
||||
BindingHelpers.AssertTypedBindingExists((ClickGestureRecognizer)gestureElement.GestureRecognizers[0], ClickGestureRecognizer.CommandParameterProperty, BindingMode.Default, gestureElement.BindingContext);
|
||||
}
|
||||
|
@ -329,8 +374,12 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
|||
|
||||
gestureElement.BindTapGesture(static (ViewModel vm) => vm.SetGuidCommand);
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||
});
|
||||
|
||||
BindingHelpers.AssertTypedBindingExists((TapGestureRecognizer)gestureElement.GestureRecognizers[0], TapGestureRecognizer.CommandProperty, BindingMode.Default, gestureElement.BindingContext);
|
||||
}
|
||||
|
||||
|
@ -350,8 +399,12 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
|||
},
|
||||
mode: BindingMode.OneTime);
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||
});
|
||||
|
||||
BindingHelpers.AssertTypedBindingExists((TapGestureRecognizer)gestureElement.GestureRecognizers[0], TapGestureRecognizer.CommandProperty, BindingMode.OneTime, gestureElement.BindingContext);
|
||||
}
|
||||
|
||||
|
@ -380,10 +433,14 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
|||
|
||||
tapGestureRecognizer.SendTapped(gestureElement);
|
||||
|
||||
Assert.That(viewModel.Id, Is.EqualTo(guid));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||
Assert.That(tapGestureRecognizer.NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(viewModel.Id, Is.EqualTo(guid));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||
Assert.That(tapGestureRecognizer.NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
||||
});
|
||||
|
||||
BindingHelpers.AssertTypedBindingExists(tapGestureRecognizer, TapGestureRecognizer.CommandProperty, BindingMode.OneTime, gestureElement.BindingContext);
|
||||
BindingHelpers.AssertTypedBindingExists(tapGestureRecognizer, TapGestureRecognizer.CommandParameterProperty, BindingMode.OneTime, gestureElement.BindingContext);
|
||||
}
|
||||
|
@ -416,9 +473,13 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
|||
|
||||
var tapGestureRecognizer = (TapGestureRecognizer)gestureElement.GestureRecognizers[0];
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||
Assert.That(tapGestureRecognizer.NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||
Assert.That(tapGestureRecognizer.NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
||||
});
|
||||
|
||||
BindingHelpers.AssertTypedBindingExists(tapGestureRecognizer, TapGestureRecognizer.CommandProperty, BindingMode.OneTime, gestureElement.BindingContext);
|
||||
BindingHelpers.AssertTypedBindingExists(tapGestureRecognizer, TapGestureRecognizer.CommandParameterProperty, BindingMode.Default, gestureElement.BindingContext);
|
||||
}
|
||||
|
@ -454,8 +515,12 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
|||
},
|
||||
mode: BindingMode.OneTime);
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
});
|
||||
|
||||
BindingHelpers.AssertTypedBindingExists((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0], SwipeGestureRecognizer.CommandProperty, BindingMode.OneTime, gestureElement.BindingContext);
|
||||
}
|
||||
|
||||
|
@ -488,11 +553,15 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
|||
|
||||
swipeGestureRecognizer.SendSwiped(gestureElement, direction);
|
||||
|
||||
Assert.That(viewModel.Id, Is.EqualTo(guid));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(viewModel.Id, Is.EqualTo(guid));
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
||||
});
|
||||
|
||||
BindingHelpers.AssertTypedBindingExists((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0], SwipeGestureRecognizer.CommandProperty, BindingMode.OneTime, gestureElement.BindingContext);
|
||||
BindingHelpers.AssertTypedBindingExists((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0], SwipeGestureRecognizer.CommandParameterProperty, BindingMode.OneTime, gestureElement.BindingContext);
|
||||
}
|
||||
|
@ -523,10 +592,14 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
|||
direction: direction,
|
||||
threshold: threshold);
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
||||
});
|
||||
|
||||
BindingHelpers.AssertTypedBindingExists((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0], SwipeGestureRecognizer.CommandProperty, BindingMode.OneTime, gestureElement.BindingContext);
|
||||
BindingHelpers.AssertTypedBindingExists((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0], SwipeGestureRecognizer.CommandParameterProperty, BindingMode.Default, gestureElement.BindingContext);
|
||||
}
|
||||
|
@ -536,16 +609,19 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
|||
public void MultipleGestureBindings()
|
||||
{
|
||||
var gestureElement = new TGestureElement
|
||||
{
|
||||
BindingContext = new ViewModel()
|
||||
}.BindSwipeGesture(static (ViewModel vm) => vm.SetGuidCommand)
|
||||
{
|
||||
BindingContext = new ViewModel()
|
||||
}.BindSwipeGesture(static (ViewModel vm) => vm.SetGuidCommand)
|
||||
.BindTapGesture(static (ViewModel vm) => vm.SetGuidCommand)
|
||||
.BindClickGesture(static (ViewModel vm) => vm.SetGuidCommand);
|
||||
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(3));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
Assert.That(gestureElement.GestureRecognizers[1], Is.InstanceOf<TapGestureRecognizer>());
|
||||
Assert.That(gestureElement.GestureRecognizers[2], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(3));
|
||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||
Assert.That(gestureElement.GestureRecognizers[1], Is.InstanceOf<TapGestureRecognizer>());
|
||||
Assert.That(gestureElement.GestureRecognizers[2], Is.InstanceOf<ClickGestureRecognizer>());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,14 @@ class GridRowsColumns : BaseMarkupTestFixture
|
|||
RowDefinitions = Rows.Define(Auto, Star, Stars(starsValue), 20)
|
||||
};
|
||||
|
||||
Assert.That(grid.RowDefinitions.Count, Is.EqualTo(4));
|
||||
Assert.That(grid.RowDefinitions[0]?.Height, Is.EqualTo(GridLength.Auto));
|
||||
Assert.That(grid.RowDefinitions[1]?.Height, Is.EqualTo(GridLength.Star));
|
||||
Assert.That(grid.RowDefinitions[2]?.Height, Is.EqualTo(starsLength));
|
||||
Assert.That(grid.RowDefinitions[3]?.Height, Is.EqualTo(new GridLength(20)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(grid.RowDefinitions.Count, Is.EqualTo(4));
|
||||
Assert.That(grid.RowDefinitions[0]?.Height, Is.EqualTo(GridLength.Auto));
|
||||
Assert.That(grid.RowDefinitions[1]?.Height, Is.EqualTo(GridLength.Star));
|
||||
Assert.That(grid.RowDefinitions[2]?.Height, Is.EqualTo(starsLength));
|
||||
Assert.That(grid.RowDefinitions[3]?.Height, Is.EqualTo(new GridLength(20)));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -41,11 +44,14 @@ class GridRowsColumns : BaseMarkupTestFixture
|
|||
)
|
||||
};
|
||||
|
||||
Assert.That(grid.RowDefinitions.Count, Is.EqualTo(4));
|
||||
Assert.That(grid.RowDefinitions[0]?.Height, Is.EqualTo(GridLength.Auto));
|
||||
Assert.That(grid.RowDefinitions[1]?.Height, Is.EqualTo(GridLength.Star));
|
||||
Assert.That(grid.RowDefinitions[2]?.Height, Is.EqualTo(starsLength));
|
||||
Assert.That(grid.RowDefinitions[3]?.Height, Is.EqualTo(new GridLength(20)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(grid.RowDefinitions.Count, Is.EqualTo(4));
|
||||
Assert.That(grid.RowDefinitions[0]?.Height, Is.EqualTo(GridLength.Auto));
|
||||
Assert.That(grid.RowDefinitions[1]?.Height, Is.EqualTo(GridLength.Star));
|
||||
Assert.That(grid.RowDefinitions[2]?.Height, Is.EqualTo(starsLength));
|
||||
Assert.That(grid.RowDefinitions[3]?.Height, Is.EqualTo(new GridLength(20)));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -65,12 +71,15 @@ class GridRowsColumns : BaseMarkupTestFixture
|
|||
ColumnDefinitions = Columns.Define(Auto, Star, Stars(starsValue), 20, 40)
|
||||
};
|
||||
|
||||
Assert.That(grid.ColumnDefinitions.Count, Is.EqualTo(5));
|
||||
Assert.That(grid.ColumnDefinitions[0]?.Width, Is.EqualTo(GridLength.Auto));
|
||||
Assert.That(grid.ColumnDefinitions[1]?.Width, Is.EqualTo(GridLength.Star));
|
||||
Assert.That(grid.ColumnDefinitions[2]?.Width, Is.EqualTo(starsLength));
|
||||
Assert.That(grid.ColumnDefinitions[3]?.Width, Is.EqualTo(new GridLength(20)));
|
||||
Assert.That(grid.ColumnDefinitions[4]?.Width, Is.EqualTo(new GridLength(40)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(grid.ColumnDefinitions.Count, Is.EqualTo(5));
|
||||
Assert.That(grid.ColumnDefinitions[0]?.Width, Is.EqualTo(GridLength.Auto));
|
||||
Assert.That(grid.ColumnDefinitions[1]?.Width, Is.EqualTo(GridLength.Star));
|
||||
Assert.That(grid.ColumnDefinitions[2]?.Width, Is.EqualTo(starsLength));
|
||||
Assert.That(grid.ColumnDefinitions[3]?.Width, Is.EqualTo(new GridLength(20)));
|
||||
Assert.That(grid.ColumnDefinitions[4]?.Width, Is.EqualTo(new GridLength(40)));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -87,12 +96,15 @@ class GridRowsColumns : BaseMarkupTestFixture
|
|||
)
|
||||
};
|
||||
|
||||
Assert.That(grid.ColumnDefinitions.Count, Is.EqualTo(5));
|
||||
Assert.That(grid.ColumnDefinitions[0]?.Width, Is.EqualTo(GridLength.Auto));
|
||||
Assert.That(grid.ColumnDefinitions[1]?.Width, Is.EqualTo(GridLength.Star));
|
||||
Assert.That(grid.ColumnDefinitions[2]?.Width, Is.EqualTo(starsLength));
|
||||
Assert.That(grid.ColumnDefinitions[3]?.Width, Is.EqualTo(new GridLength(20)));
|
||||
Assert.That(grid.ColumnDefinitions[4]?.Width, Is.EqualTo(new GridLength(40)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(grid.ColumnDefinitions.Count, Is.EqualTo(5));
|
||||
Assert.That(grid.ColumnDefinitions[0]?.Width, Is.EqualTo(GridLength.Auto));
|
||||
Assert.That(grid.ColumnDefinitions[1]?.Width, Is.EqualTo(GridLength.Star));
|
||||
Assert.That(grid.ColumnDefinitions[2]?.Width, Is.EqualTo(starsLength));
|
||||
Assert.That(grid.ColumnDefinitions[3]?.Width, Is.EqualTo(new GridLength(20)));
|
||||
Assert.That(grid.ColumnDefinitions[4]?.Width, Is.EqualTo(new GridLength(40)));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -17,8 +17,12 @@ class ObjectExtensionsTests : BaseMarkupTestFixture
|
|||
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));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(ReferenceEquals(createdLabel, assignedLabel));
|
||||
Assert.That(ReferenceEquals(assignedCustomLabel, assignedLabel));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -29,11 +33,14 @@ class ObjectExtensionsTests : BaseMarkupTestFixture
|
|||
|
||||
var createdString = text.Invoke(_ => testString = text).Assign(out string assignedString);
|
||||
|
||||
Assert.That(testString, Is.Not.Null);
|
||||
Assert.That(testString, Is.EqualTo(text));
|
||||
Assert.That(assignedString, Is.EqualTo(text));
|
||||
Assert.That(createdString, Is.EqualTo(text));
|
||||
Assert.That(ReferenceEquals(createdString, assignedString));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(testString, Is.Not.Null);
|
||||
Assert.That(testString, Is.EqualTo(text));
|
||||
Assert.That(assignedString, Is.EqualTo(text));
|
||||
Assert.That(createdString, Is.EqualTo(text));
|
||||
Assert.That(ReferenceEquals(createdString, assignedString));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -24,8 +24,12 @@ class StyleTests : BaseMarkupTestFixture
|
|||
Assert.That(formsStyle.Setters.Count, Is.EqualTo(1));
|
||||
|
||||
var setter = formsStyle.Setters[0];
|
||||
Assert.That(setter.Property, Is.EqualTo(Label.TextColorProperty));
|
||||
Assert.That(setter.Value, Is.EqualTo(Colors.Red));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(setter.Property, Is.EqualTo(Label.TextColorProperty));
|
||||
Assert.That(setter.Value, Is.EqualTo(Colors.Red));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -39,12 +43,20 @@ class StyleTests : BaseMarkupTestFixture
|
|||
Assert.That(formsStyle.Setters.Count, Is.EqualTo(2));
|
||||
|
||||
var setter1 = formsStyle.Setters[0];
|
||||
Assert.That(setter1.Property, Is.EqualTo(Label.TextColorProperty));
|
||||
Assert.That(setter1.Value, Is.EqualTo(Colors.Red));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(setter1.Property, Is.EqualTo(Label.TextColorProperty));
|
||||
Assert.That(setter1.Value, Is.EqualTo(Colors.Red));
|
||||
});
|
||||
|
||||
var setter2 = formsStyle.Setters[1];
|
||||
Assert.That(setter2.Property, Is.EqualTo(Label.TranslationXProperty));
|
||||
Assert.That(setter2.Value, Is.EqualTo(8.0));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(setter2.Property, Is.EqualTo(Label.TranslationXProperty));
|
||||
Assert.That(setter2.Value, Is.EqualTo(8.0));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -86,8 +98,12 @@ class StyleTests : BaseMarkupTestFixture
|
|||
Assert.That(formsStyle.Setters.Count, Is.EqualTo(1));
|
||||
|
||||
var setter = formsStyle.Setters[0];
|
||||
Assert.That(setter.Property, Is.EqualTo(Label.TextColorProperty));
|
||||
Assert.That(setter.Value, Is.EqualTo(Colors.Red));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(setter.Property, Is.EqualTo(Label.TextColorProperty));
|
||||
Assert.That(setter.Value, Is.EqualTo(Colors.Red));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -104,12 +120,20 @@ class StyleTests : BaseMarkupTestFixture
|
|||
Assert.That(formsStyle.Setters.Count, Is.EqualTo(2));
|
||||
|
||||
var setter1 = formsStyle.Setters[0];
|
||||
Assert.That(setter1.Property, Is.EqualTo(Label.TextColorProperty));
|
||||
Assert.That(setter1.Value, Is.EqualTo(Colors.Red));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(setter1.Property, Is.EqualTo(Label.TextColorProperty));
|
||||
Assert.That(setter1.Value, Is.EqualTo(Colors.Red));
|
||||
});
|
||||
|
||||
var setter2 = formsStyle.Setters[1];
|
||||
Assert.That(setter2.Property, Is.EqualTo(Label.TranslationXProperty));
|
||||
Assert.That(setter2.Value, Is.EqualTo(8.0));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(setter2.Property, Is.EqualTo(Label.TranslationXProperty));
|
||||
Assert.That(setter2.Value, Is.EqualTo(8.0));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -122,8 +146,11 @@ class StyleTests : BaseMarkupTestFixture
|
|||
|
||||
style.Add(behavior);
|
||||
|
||||
Assert.That(formsStyle.Behaviors.Count, Is.EqualTo(1));
|
||||
Assert.That(ReferenceEquals(formsStyle.Behaviors[0], behavior));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(formsStyle.Behaviors.Count, Is.EqualTo(1));
|
||||
Assert.That(ReferenceEquals(formsStyle.Behaviors[0], behavior));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -137,9 +164,12 @@ class StyleTests : BaseMarkupTestFixture
|
|||
|
||||
style.Add(behavior1, behavior2);
|
||||
|
||||
Assert.That(formsStyle.Behaviors.Count, Is.EqualTo(2));
|
||||
Assert.That(ReferenceEquals(formsStyle.Behaviors[0], behavior1));
|
||||
Assert.That(ReferenceEquals(formsStyle.Behaviors[1], behavior2));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(formsStyle.Behaviors.Count, Is.EqualTo(2));
|
||||
Assert.That(ReferenceEquals(formsStyle.Behaviors[0], behavior1));
|
||||
Assert.That(ReferenceEquals(formsStyle.Behaviors[1], behavior2));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -152,8 +182,11 @@ class StyleTests : BaseMarkupTestFixture
|
|||
|
||||
style.Add(trigger);
|
||||
|
||||
Assert.That(formsStyle.Triggers.Count, Is.EqualTo(1));
|
||||
Assert.That(ReferenceEquals(formsStyle.Triggers[0], trigger));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(formsStyle.Triggers.Count, Is.EqualTo(1));
|
||||
Assert.That(ReferenceEquals(formsStyle.Triggers[0], trigger));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -167,9 +200,12 @@ class StyleTests : BaseMarkupTestFixture
|
|||
|
||||
style.Add(trigger1, trigger2);
|
||||
|
||||
Assert.That(formsStyle.Triggers.Count, Is.EqualTo(2));
|
||||
Assert.That(ReferenceEquals(formsStyle.Triggers[0], trigger1));
|
||||
Assert.That(ReferenceEquals(formsStyle.Triggers[1], trigger2));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(formsStyle.Triggers.Count, Is.EqualTo(2));
|
||||
Assert.That(ReferenceEquals(formsStyle.Triggers[0], trigger1));
|
||||
Assert.That(ReferenceEquals(formsStyle.Triggers[1], trigger2));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -197,11 +233,14 @@ class StyleTests : BaseMarkupTestFixture
|
|||
.Add(new Trigger(typeof(Label)))
|
||||
.CanCascade(true);
|
||||
|
||||
Assert.That(style.MauiStyle.CanCascade, Is.True);
|
||||
Assert.That(style.MauiStyle.Setters[0].Value, Is.EqualTo(Colors.Red));
|
||||
Assert.That(style.MauiStyle.Behaviors[0], Is.InstanceOf<LabelBehavior>());
|
||||
Assert.That(style.MauiStyle.Triggers[0], Is.InstanceOf<Trigger>());
|
||||
Assert.That(style.MauiStyle.CanBeAppliedTo(typeof(Label)), Is.True);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(style.MauiStyle.CanCascade, Is.True);
|
||||
Assert.That(style.MauiStyle.Setters[0].Value, Is.EqualTo(Colors.Red));
|
||||
Assert.That(style.MauiStyle.Behaviors[0], Is.InstanceOf<LabelBehavior>());
|
||||
Assert.That(style.MauiStyle.Triggers[0], Is.InstanceOf<Trigger>());
|
||||
Assert.That(style.MauiStyle.CanBeAppliedTo(typeof(Label)), Is.True);
|
||||
});
|
||||
}
|
||||
|
||||
[TestCase(AppTheme.Light)]
|
||||
|
@ -235,8 +274,11 @@ class StyleTests : BaseMarkupTestFixture
|
|||
.AppThemeBinding(Label.TextProperty, nameof(AppTheme.Light), nameof(AppTheme.Dark)),
|
||||
(label) =>
|
||||
{
|
||||
Assert.That(label.TextColor, Is.EqualTo(expectedColor));
|
||||
Assert.That(label.Text, Is.EqualTo(expectedText));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(label.TextColor, Is.EqualTo(expectedColor));
|
||||
Assert.That(label.Text, Is.EqualTo(expectedText));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -153,8 +153,11 @@ namespace CommunityToolkit.Maui.Markup.UnitTests
|
|||
|
||||
var generatedPicker = genericPicker.TextEnd();
|
||||
|
||||
Assert.That(genericPicker.HorizontalTextAlignment, Is.EqualTo(TextAlignment.End));
|
||||
Assert.That(generatedPicker, Is.InstanceOf<MyGenericPicker<string>>());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(genericPicker.HorizontalTextAlignment, Is.EqualTo(TextAlignment.End));
|
||||
Assert.That(generatedPicker, Is.InstanceOf<MyGenericPicker<string>>());
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -391,8 +394,11 @@ namespace CommunityToolkit.Maui.Markup.UnitTests
|
|||
.TextBottom()
|
||||
.TextCenter();
|
||||
|
||||
Assert.That(partialClassControl.IsPartial, Is.True);
|
||||
Assert.That(partialClassControl, Is.InstanceOf<PartialClassControl>());
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(partialClassControl.IsPartial, Is.True);
|
||||
Assert.That(partialClassControl, Is.InstanceOf<PartialClassControl>());
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -83,8 +83,11 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
|||
BindingHelpers.AssertTypedBindingExists(textCell, TextCell.CommandProperty, BindingMode.OneTime, viewModel);
|
||||
BindingHelpers.AssertTypedBindingExists(textCell, TextCell.CommandParameterProperty, BindingMode.OneWay, viewModel);
|
||||
|
||||
Assert.That(viewModel.Command, Is.EqualTo(textCell.Command));
|
||||
Assert.That(viewModel.Id, Is.EqualTo(textCell.CommandParameter));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(viewModel.Command, Is.EqualTo(textCell.Command));
|
||||
Assert.That(viewModel.Id, Is.EqualTo(textCell.CommandParameter));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -107,14 +110,21 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
|||
Assert.That(label.Text, Is.EqualTo(string.Format(stringFormat, ViewModel.DefaultPercentage)));
|
||||
|
||||
label.Text = string.Format(stringFormat, 0.1);
|
||||
Assert.That(label.Text, Is.EqualTo("0.1%"));
|
||||
Assert.That(viewModel.Percentage, Is.EqualTo(ViewModel.DefaultPercentage));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(label.Text, Is.EqualTo("0.1%"));
|
||||
Assert.That(viewModel.Percentage, Is.EqualTo(ViewModel.DefaultPercentage));
|
||||
});
|
||||
|
||||
viewModel.Percentage = 0.6;
|
||||
var propertyName = await propertyChangedEventArgsTCS.Task;
|
||||
|
||||
Assert.That(didPropertyChangeFire, Is.True);
|
||||
Assert.That(propertyName, Is.EqualTo(nameof(ViewModel.Percentage)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(didPropertyChangeFire, Is.True);
|
||||
Assert.That(propertyName, Is.EqualTo(nameof(ViewModel.Percentage)));
|
||||
});
|
||||
|
||||
void HandlePropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
|
@ -149,18 +159,25 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
|||
var viewModelPropertyName = await viewModelPropertyChangedEventArgsTCS.Task;
|
||||
var labelPropertyName = await labelPropertyChangedEventArgsTCS.Task;
|
||||
|
||||
Assert.That(didViewModelPropertyChangeFire, Is.True);
|
||||
Assert.That(viewModelPropertyName, Is.EqualTo(nameof(ViewModel.TextColor)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(didViewModelPropertyChangeFire, Is.True);
|
||||
Assert.That(viewModelPropertyName, Is.EqualTo(nameof(ViewModel.TextColor)));
|
||||
|
||||
Assert.That(didLabelPropertyChangeFire, Is.True);
|
||||
Assert.That(labelPropertyName, Is.EqualTo(nameof(Label.TextColor)));
|
||||
Assert.That(didLabelPropertyChangeFire, Is.True);
|
||||
Assert.That(labelPropertyName, Is.EqualTo(nameof(Label.TextColor)));
|
||||
|
||||
Assert.That(viewModel.TextColor, Is.EqualTo(Colors.Green));
|
||||
Assert.That(label.GetValue(Label.TextColorProperty), Is.EqualTo(Colors.Green));
|
||||
Assert.That(viewModel.TextColor, Is.EqualTo(Colors.Green));
|
||||
Assert.That(label.GetValue(Label.TextColorProperty), Is.EqualTo(Colors.Green));
|
||||
});
|
||||
|
||||
label.TextColor = Colors.Red;
|
||||
Assert.That(label.TextColor, Is.EqualTo(Colors.Red));
|
||||
Assert.That(viewModel.TextColor, Is.EqualTo(Colors.Green));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(label.TextColor, Is.EqualTo(Colors.Red));
|
||||
Assert.That(viewModel.TextColor, Is.EqualTo(Colors.Green));
|
||||
});
|
||||
|
||||
void HandleViewModelPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
|
@ -195,15 +212,22 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
|||
Assert.That(label.TextColor, Is.EqualTo(ViewModel.DefaultColor));
|
||||
|
||||
viewModel.TextColor = Colors.Green;
|
||||
Assert.That(viewModel.TextColor, Is.EqualTo(Colors.Green));
|
||||
Assert.That(label.GetValue(Label.TextColorProperty), Is.EqualTo(ViewModel.DefaultColor));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(viewModel.TextColor, Is.EqualTo(Colors.Green));
|
||||
Assert.That(label.GetValue(Label.TextColorProperty), Is.EqualTo(ViewModel.DefaultColor));
|
||||
});
|
||||
|
||||
label.TextColor = Colors.Red;
|
||||
Assert.That(label.TextColor, Is.EqualTo(Colors.Red));
|
||||
Assert.That(viewModel.TextColor, Is.EqualTo(Colors.Green));
|
||||
|
||||
Assert.That(didViewModelPropertyChangeFire, Is.True);
|
||||
Assert.That(didLabelPropertyChangeFire, Is.True);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(label.TextColor, Is.EqualTo(Colors.Red));
|
||||
Assert.That(viewModel.TextColor, Is.EqualTo(Colors.Green));
|
||||
|
||||
Assert.That(didViewModelPropertyChangeFire, Is.True);
|
||||
Assert.That(didLabelPropertyChangeFire, Is.True);
|
||||
});
|
||||
|
||||
void HandleViewModelPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
|
@ -241,23 +265,30 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
|||
Assert.That(slider.Value, Is.EqualTo(ViewModel.DefaultPercentage));
|
||||
|
||||
slider.Value = 1;
|
||||
Assert.That(slider.Value, Is.EqualTo(1));
|
||||
Assert.That(viewModel.Percentage, Is.EqualTo(1));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(slider.Value, Is.EqualTo(1));
|
||||
Assert.That(viewModel.Percentage, Is.EqualTo(1));
|
||||
});
|
||||
|
||||
viewModel.Percentage = 0.6;
|
||||
var viewModelPropertyName = await viewModelPropertyChangedEventArgsTCS.Task;
|
||||
var sliderPropertyName = await sliderPropertyChangedEventArgsTCS.Task;
|
||||
|
||||
Assert.That(didViewModelPropertyChangeFire, Is.True);
|
||||
Assert.That(viewModelPropertyName, Is.EqualTo(nameof(ViewModel.Percentage)));
|
||||
Assert.That(viewModelPropertyChangedEventCount, Is.EqualTo(2));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(didViewModelPropertyChangeFire, Is.True);
|
||||
Assert.That(viewModelPropertyName, Is.EqualTo(nameof(ViewModel.Percentage)));
|
||||
Assert.That(viewModelPropertyChangedEventCount, Is.EqualTo(2));
|
||||
|
||||
Assert.That(didSliderPropertyChangeFire, Is.True);
|
||||
Assert.That(sliderPropertyName, Is.EqualTo(nameof(Slider.Value)));
|
||||
Assert.That(sliderPropertyChangedEventCount, Is.EqualTo(2));
|
||||
Assert.That(didSliderPropertyChangeFire, Is.True);
|
||||
Assert.That(sliderPropertyName, Is.EqualTo(nameof(Slider.Value)));
|
||||
Assert.That(sliderPropertyChangedEventCount, Is.EqualTo(2));
|
||||
|
||||
Assert.That(slider.Value, Is.EqualTo(0.6));
|
||||
Assert.That(viewModel.Percentage, Is.EqualTo(0.6));
|
||||
Assert.That(slider.Value, Is.EqualTo(0.6));
|
||||
Assert.That(viewModel.Percentage, Is.EqualTo(0.6));
|
||||
});
|
||||
|
||||
void HandleViewModelPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
|
@ -333,14 +364,21 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
|||
entry.BindingContext = viewmodel;
|
||||
}
|
||||
|
||||
Assert.That(viewmodel.Model.Model.TextColor, Is.EqualTo(ViewModel.DefaultColor));
|
||||
Assert.That(entry.GetValue(Entry.TextColorProperty), Is.EqualTo(ViewModel.DefaultColor));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(viewmodel.Model.Model.TextColor, Is.EqualTo(ViewModel.DefaultColor));
|
||||
Assert.That(entry.GetValue(Entry.TextColorProperty), Is.EqualTo(ViewModel.DefaultColor));
|
||||
});
|
||||
|
||||
var textColor = Colors.Pink;
|
||||
|
||||
viewmodel.Model.Model.TextColor = textColor;
|
||||
Assert.That(viewmodel.Model.Model.TextColor, Is.EqualTo(textColor));
|
||||
Assert.That(entry.GetValue(Entry.TextColorProperty), Is.EqualTo(textColor));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(viewmodel.Model.Model.TextColor, Is.EqualTo(textColor));
|
||||
Assert.That(entry.GetValue(Entry.TextColorProperty), Is.EqualTo(textColor));
|
||||
});
|
||||
}
|
||||
|
||||
[TestCase(false, false)]
|
||||
|
@ -406,14 +444,20 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
|||
label.BindingContext = viewmodel;
|
||||
}
|
||||
|
||||
Assert.That(viewmodel.Model.Model.TextColor, Is.EqualTo(ViewModel.DefaultColor));
|
||||
Assert.That(label.GetValue(Label.TextProperty), Is.EqualTo(colorToHexRgbStringConverter.ConvertFrom(ViewModel.DefaultColor)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(viewmodel.Model.Model.TextColor, Is.EqualTo(ViewModel.DefaultColor));
|
||||
Assert.That(label.GetValue(Label.TextProperty), Is.EqualTo(colorToHexRgbStringConverter.ConvertFrom(ViewModel.DefaultColor)));
|
||||
});
|
||||
|
||||
var textColor = Colors.Pink;
|
||||
|
||||
viewmodel.Model.Model.TextColor = textColor;
|
||||
Assert.That(viewmodel.Model.Model.TextColor, Is.EqualTo(textColor));
|
||||
Assert.That(label.GetValue(Label.TextProperty), Is.EqualTo(colorToHexRgbStringConverter.ConvertFrom(textColor)));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(viewmodel.Model.Model.TextColor, Is.EqualTo(textColor));
|
||||
Assert.That(label.GetValue(Label.TextProperty), Is.EqualTo(colorToHexRgbStringConverter.ConvertFrom(textColor)));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -453,14 +497,17 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
|||
var viewModelPropertyName = await viewModelPropertyChangedEventArgsTCS.Task;
|
||||
var labelPropertyName = await labelPropertyChangedEventArgsTCS.Task;
|
||||
|
||||
Assert.That(didViewModelPropertyChangeFire, Is.True);
|
||||
Assert.That(viewModelPropertyName, Is.EqualTo(nameof(ViewModel.TextColor)));
|
||||
Assert.That(viewModelPropertyChangedEventCount, Is.EqualTo(1));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(didViewModelPropertyChangeFire, Is.True);
|
||||
Assert.That(viewModelPropertyName, Is.EqualTo(nameof(ViewModel.TextColor)));
|
||||
Assert.That(viewModelPropertyChangedEventCount, Is.EqualTo(1));
|
||||
|
||||
Assert.That(didLabelPropertyChangeFire, Is.True);
|
||||
Assert.That(labelPropertyName, Is.EqualTo(nameof(Label.Text)));
|
||||
Assert.That(labelPropertyChangedEventCount, Is.EqualTo(1));
|
||||
Assert.That(colorToHexRgbStringConverter.ConvertFrom(updatedTextColor), Is.EqualTo(label.Text));
|
||||
Assert.That(didLabelPropertyChangeFire, Is.True);
|
||||
Assert.That(labelPropertyName, Is.EqualTo(nameof(Label.Text)));
|
||||
Assert.That(labelPropertyChangedEventCount, Is.EqualTo(1));
|
||||
Assert.That(colorToHexRgbStringConverter.ConvertFrom(updatedTextColor), Is.EqualTo(label.Text));
|
||||
});
|
||||
|
||||
void HandleViewModelPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
|
@ -511,14 +558,17 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
|||
var viewModelPropertyName = await viewModelPropertyChangedEventArgsTCS.Task;
|
||||
var sliderPropertyName = await sliderPropertyChangedEventArgsTCS.Task;
|
||||
|
||||
Assert.That(didViewModelPropertyChangeFire, Is.True);
|
||||
Assert.That(viewModelPropertyName, Is.EqualTo(nameof(ViewModel.Percentage)));
|
||||
Assert.That(viewModelPropertyChangedEventCount, Is.EqualTo(1));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(didViewModelPropertyChangeFire, Is.True);
|
||||
Assert.That(viewModelPropertyName, Is.EqualTo(nameof(ViewModel.Percentage)));
|
||||
Assert.That(viewModelPropertyChangedEventCount, Is.EqualTo(1));
|
||||
|
||||
Assert.That(didSliderPropertyChangeFire, Is.True);
|
||||
Assert.That(sliderPropertyName, Is.EqualTo(nameof(Slider.ThumbColor)));
|
||||
Assert.That(sliderPropertyChangedEventCount, Is.EqualTo(1));
|
||||
Assert.That(slider.ThumbColor, Is.EqualTo(Colors.Green));
|
||||
Assert.That(didSliderPropertyChangeFire, Is.True);
|
||||
Assert.That(sliderPropertyName, Is.EqualTo(nameof(Slider.ThumbColor)));
|
||||
Assert.That(sliderPropertyChangedEventCount, Is.EqualTo(1));
|
||||
Assert.That(slider.ThumbColor, Is.EqualTo(Colors.Green));
|
||||
});
|
||||
|
||||
void HandleViewModelPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
|
|
|
@ -44,8 +44,12 @@ class VisualElementExtensionsTests : BaseMarkupTestFixture<BoxView>
|
|||
{
|
||||
Bindable.WidthRequest = Bindable.HeightRequest = 1;
|
||||
Bindable.Size(2, 3);
|
||||
Assert.That(Bindable.WidthRequest, Is.EqualTo(2));
|
||||
Assert.That(Bindable.HeightRequest, Is.EqualTo(3));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(Bindable.WidthRequest, Is.EqualTo(2));
|
||||
Assert.That(Bindable.HeightRequest, Is.EqualTo(3));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -53,8 +57,12 @@ class VisualElementExtensionsTests : BaseMarkupTestFixture<BoxView>
|
|||
{
|
||||
Bindable.WidthRequest = Bindable.HeightRequest = 1;
|
||||
Bindable.Size(2);
|
||||
Assert.That(Bindable.WidthRequest, Is.EqualTo(2));
|
||||
Assert.That(Bindable.HeightRequest, Is.EqualTo(2));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(Bindable.WidthRequest, Is.EqualTo(2));
|
||||
Assert.That(Bindable.HeightRequest, Is.EqualTo(2));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -62,8 +70,12 @@ class VisualElementExtensionsTests : BaseMarkupTestFixture<BoxView>
|
|||
{
|
||||
Bindable.MinimumWidthRequest = Bindable.MinimumHeightRequest = 1;
|
||||
Bindable.MinSize(2, 3);
|
||||
Assert.That(Bindable.MinimumWidthRequest, Is.EqualTo(2));
|
||||
Assert.That(Bindable.MinimumHeightRequest, Is.EqualTo(3));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(Bindable.MinimumWidthRequest, Is.EqualTo(2));
|
||||
Assert.That(Bindable.MinimumHeightRequest, Is.EqualTo(3));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -71,8 +83,12 @@ class VisualElementExtensionsTests : BaseMarkupTestFixture<BoxView>
|
|||
{
|
||||
Bindable.MinimumWidthRequest = Bindable.MinimumHeightRequest = 1;
|
||||
Bindable.MinSize(2);
|
||||
Assert.That(Bindable.MinimumWidthRequest, Is.EqualTo(2));
|
||||
Assert.That(Bindable.MinimumHeightRequest, Is.EqualTo(2));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(Bindable.MinimumWidthRequest, Is.EqualTo(2));
|
||||
Assert.That(Bindable.MinimumHeightRequest, Is.EqualTo(2));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -93,8 +109,12 @@ class VisualElementExtensionsTests : BaseMarkupTestFixture<BoxView>
|
|||
public void Anchor()
|
||||
{
|
||||
Bindable.Anchor(50, 75);
|
||||
Assert.That(Bindable.AnchorX, Is.EqualTo(50));
|
||||
Assert.That(Bindable.AnchorY, Is.EqualTo(75));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(Bindable.AnchorX, Is.EqualTo(50));
|
||||
Assert.That(Bindable.AnchorY, Is.EqualTo(75));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -231,16 +251,24 @@ class VisualElementExtensionsTests : BaseMarkupTestFixture<BoxView>
|
|||
public void Scale_Different()
|
||||
{
|
||||
Bindable.Scale(2, 3);
|
||||
Assert.That(Bindable.ScaleX, Is.EqualTo(2));
|
||||
Assert.That(Bindable.ScaleY, Is.EqualTo(3));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(Bindable.ScaleX, Is.EqualTo(2));
|
||||
Assert.That(Bindable.ScaleY, Is.EqualTo(3));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Scale_Same()
|
||||
{
|
||||
Bindable.Scale(1.25);
|
||||
Assert.That(Bindable.ScaleX, Is.EqualTo(1.25));
|
||||
Assert.That(Bindable.ScaleY, Is.EqualTo(1.25));
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(Bindable.ScaleX, Is.EqualTo(1.25));
|
||||
Assert.That(Bindable.ScaleY, Is.EqualTo(1.25));
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
Загрузка…
Ссылка в новой задаче