[Housekeeping] Utilize NUnit.Analyzers for Unit Tests (#311)
This commit is contained in:
Родитель
2123e6752f
Коммит
a9a6f5eedf
|
@ -40,14 +40,16 @@
|
||||||
CS1712: Type parameter has no matching typeparam tag in the XML comment
|
CS1712: Type parameter has no matching typeparam tag in the XML comment
|
||||||
CS1723: XML comment has cref attribute that refers to a type parameter
|
CS1723: XML comment has cref attribute that refers to a type parameter
|
||||||
CS1734: XML comment has a paramref tag, but there is no parameter by that name
|
CS1734: XML comment has a paramref tag, but there is no parameter by that name
|
||||||
xUnit1012: Null should not be used for type parameter
|
NUnit*: NUnit Analyzers
|
||||||
xUnit2021: Assert.ThrowsAsync is async. The resulting task should be awaited
|
|
||||||
IL2***: Trim Warnings
|
IL2***: Trim Warnings
|
||||||
IL3***: AOT Warnings-->
|
IL3***: AOT Warnings-->
|
||||||
<WarningsAsErrors>
|
<WarningsAsErrors>
|
||||||
nullable,
|
nullable,
|
||||||
CS0419,CS1570,CS1571,CS1572,CS1573,CS1574,CS1580,CS1581,CS1584,CS1587,CS1589,CS1590,CS1591,CS1592,CS1598,CS1658,CS1710,CS1711,CS1712,CS1723,CS1734,
|
CS0419,CS1570,CS1571,CS1572,CS1573,CS1574,CS1580,CS1581,CS1584,CS1587,CS1589,CS1590,CS1591,CS1592,CS1598,CS1658,CS1710,CS1711,CS1712,CS1723,CS1734,
|
||||||
xUnit1012,xUnit2021,
|
NUnit1001,NUnit1002,NUnit1003,NUnit1004,NUnit1005,NUnit1006,NUnit1007,NUnit1008,NUnit1009,NUnit1010,NUnit1011,NUnit1012,NUnit1013,NUnit1014,NUnit1015,NUnit1016,NUnit1017,NUnit1018,NUnit1019,NUnit1020,NUnit1021,NUnit1022,NUnit1023,NUnit1024,NUnit1025,NUnit1026,NUnit1027,NUnit1028,NUnit1029,NUnit1030,NUnit1031,NUnit1032,NUnit1033,
|
||||||
|
NUnit2001,NUnit2002,NUnit2003,NUnit2004,NUnit2005,NUnit2006,NUnit2007,NUnit2008,NUnit2009,NUnit2010,NUnit2011,NUnit2012,NUnit2013,NUnit2014,NUnit2015,NUnit2016,NUnit2017,NUnit2018,NUnit2019,NUnit2020,NUnit2021,NUnit2022,NUnit2023,NUnit2024,NUnit2025,NUnit2026,NUnit2027,NUnit2028,NUnit2029,NUnit2030,NUnit2031,NUnit2032,NUnit2033,NUnit2034,NUnit2035,NUnit2036,NUnit2037,NUnit2038,NUnit2039,NUnit2040,NUnit2041,NUnit2042,NUnit2043,NUnit2044,NUnit2045,NUnit2046,NUnit2047,NUnit2048,NUnit2049,NUnit2050,
|
||||||
|
NUnit3001,NUnit3002,NUnit3003,NUnit3004,
|
||||||
|
NUnit4001
|
||||||
IL2001,IL2002,IL2003,IL2004,IL2005,IL2006,IL2007,IL2008,IL2009,
|
IL2001,IL2002,IL2003,IL2004,IL2005,IL2006,IL2007,IL2008,IL2009,
|
||||||
IL2010,IL2011,IL2012,IL2013,IL2014,IL2015,IL2016,IL2017,IL2018,IL2019,
|
IL2010,IL2011,IL2012,IL2013,IL2014,IL2015,IL2016,IL2017,IL2018,IL2019,
|
||||||
IL2020,IL2021,IL2022,IL2023,IL2024,IL2025,IL2026,IL2027,IL2028,IL2029,
|
IL2020,IL2021,IL2022,IL2023,IL2024,IL2025,IL2026,IL2027,IL2028,IL2029,
|
||||||
|
@ -62,7 +64,7 @@
|
||||||
IL2110,IL2111,IL2112,IL2113,IL2114,IL2115,IL2116,IL2117,IL2118,IL2119,
|
IL2110,IL2111,IL2112,IL2113,IL2114,IL2115,IL2116,IL2117,IL2118,IL2119,
|
||||||
IL2120,IL2121,IL2122,
|
IL2120,IL2121,IL2122,
|
||||||
IL3050,IL3051,IL3052,IL3053,IL3054,IL3055,IL3056
|
IL3050,IL3051,IL3052,IL3053,IL3054,IL3055,IL3056
|
||||||
</WarningsAsErrors>
|
</WarningsAsErrors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -4,12 +4,12 @@ namespace CommunityToolkit.Maui.Markup.Sample;
|
||||||
|
|
||||||
class AppShell : Shell
|
class AppShell : Shell
|
||||||
{
|
{
|
||||||
static readonly IReadOnlyDictionary<Type, string> pageRouteMappingDictionary = new Dictionary<Type, string>(new[]
|
static readonly IReadOnlyDictionary<Type, string> pageRouteMappingDictionary = new Dictionary<Type, string>(
|
||||||
{
|
[
|
||||||
CreateRoutePageMapping<NewsPage, NewsViewModel>(),
|
CreateRoutePageMapping<NewsPage, NewsViewModel>(),
|
||||||
CreateRoutePageMapping<SettingsPage, SettingsViewModel>(),
|
CreateRoutePageMapping<SettingsPage, SettingsViewModel>(),
|
||||||
CreateRoutePageMapping<NewsDetailPage, NewsDetailViewModel>(),
|
CreateRoutePageMapping<NewsDetailPage, NewsDetailViewModel>()
|
||||||
});
|
]);
|
||||||
|
|
||||||
public AppShell(NewsPage newsPage)
|
public AppShell(NewsPage newsPage)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,7 @@ sealed partial class NewsViewModel : BaseViewModel, IDisposable
|
||||||
remove => pullToRefreshEventManager.RemoveEventHandler(value);
|
remove => pullToRefreshEventManager.RemoveEventHandler(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableCollection<StoryModel> TopStoryCollection { get; } = new();
|
public ObservableCollection<StoryModel> TopStoryCollection { get; } = [];
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ class AutomationPropertiesExtensionsTests : BaseMarkupTestFixture<Label>
|
||||||
const bool isExcluded = true;
|
const bool isExcluded = true;
|
||||||
Bindable.AutomationExcludedWithChildren(isExcluded);
|
Bindable.AutomationExcludedWithChildren(isExcluded);
|
||||||
|
|
||||||
Assert.That(AutomationProperties.GetExcludedWithChildren(Bindable) == isExcluded);
|
Assert.That(AutomationProperties.GetExcludedWithChildren(Bindable), Is.EqualTo(isExcluded));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -21,6 +21,6 @@ class AutomationPropertiesExtensionsTests : BaseMarkupTestFixture<Label>
|
||||||
const bool isInTree = false;
|
const bool isInTree = false;
|
||||||
Bindable.AutomationIsInAccessibleTree(isInTree);
|
Bindable.AutomationIsInAccessibleTree(isInTree);
|
||||||
|
|
||||||
Assert.That(AutomationProperties.GetIsInAccessibleTree(Bindable) == isInTree);
|
Assert.That(AutomationProperties.GetIsInAccessibleTree(Bindable), Is.EqualTo(isInTree));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,23 +17,27 @@ class BindableObjectMultiBindExtensionsTests : BaseMarkupTestFixture
|
||||||
|
|
||||||
viewModel = new ViewModel();
|
viewModel = new ViewModel();
|
||||||
|
|
||||||
testBindings = new List<BindingBase>
|
testBindings =
|
||||||
{
|
[
|
||||||
new Binding(nameof(viewModel.Text)),
|
new Binding(nameof(viewModel.Text)),
|
||||||
new Binding(nameof(viewModel.Id)),
|
new Binding(nameof(viewModel.Id)),
|
||||||
|
|
||||||
new Binding(nameof(viewModel.IsDone)),
|
new Binding(nameof(viewModel.IsDone)),
|
||||||
new Binding(nameof(viewModel.Fraction)),
|
new Binding(nameof(viewModel.Fraction)),
|
||||||
new Binding(nameof(viewModel.Count))
|
|
||||||
};
|
|
||||||
|
|
||||||
testConvertValues = new List<object>
|
new Binding(nameof(viewModel.Count))
|
||||||
{
|
];
|
||||||
|
|
||||||
|
testConvertValues =
|
||||||
|
[
|
||||||
"Hi",
|
"Hi",
|
||||||
Guid.Parse("{272383A4-92E3-46BA-99DC-438D81E039AB}"),
|
Guid.Parse("{272383A4-92E3-46BA-99DC-438D81E039AB}"),
|
||||||
|
|
||||||
true,
|
true,
|
||||||
0.5,
|
0.5,
|
||||||
|
|
||||||
3
|
3
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
[TearDown]
|
[TearDown]
|
||||||
|
@ -425,7 +429,7 @@ class BindableObjectMultiBindExtensionsTests : BaseMarkupTestFixture
|
||||||
ArgumentNullException.ThrowIfNull(formatted);
|
ArgumentNullException.ThrowIfNull(formatted);
|
||||||
|
|
||||||
var result = Unformat(0, formatted);
|
var result = Unformat(0, formatted);
|
||||||
return new object[] { result.Text ?? string.Empty, result.Id, result.IsDone, result.Fraction, result.Count };
|
return [result.Text ?? string.Empty, result.Id, result.IsDone, result.Fraction, result.Count];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,7 +459,7 @@ class BindableObjectMultiBindExtensionsTests : BaseMarkupTestFixture
|
||||||
ArgumentNullException.ThrowIfNull(text);
|
ArgumentNullException.ThrowIfNull(text);
|
||||||
|
|
||||||
var unformattedResult = Unformat(parameter, text);
|
var unformattedResult = Unformat(parameter, text);
|
||||||
return new object[] { unformattedResult.Text ?? string.Empty, unformattedResult.Id, unformattedResult.IsDone, unformattedResult.Fraction, unformattedResult.Count };
|
return [unformattedResult.Text ?? string.Empty, unformattedResult.Id, unformattedResult.IsDone, unformattedResult.Fraction, unformattedResult.Count];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,10 +216,7 @@ static class BindingHelpers
|
||||||
{
|
{
|
||||||
getContextMethodInfo ??= typeof(BindableObject).GetMethod("GetContext", BindingFlags.NonPublic | BindingFlags.Instance);
|
getContextMethodInfo ??= typeof(BindableObject).GetMethod("GetContext", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
|
||||||
var context = getContextMethodInfo?.Invoke(bindable, new object[]
|
var context = getContextMethodInfo?.Invoke(bindable, [property]);
|
||||||
{
|
|
||||||
property
|
|
||||||
});
|
|
||||||
if (context is null)
|
if (context is null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -253,7 +250,7 @@ static class BindingHelpers
|
||||||
|
|
||||||
if (twoWay || backOnly)
|
if (twoWay || backOnly)
|
||||||
{
|
{
|
||||||
Assert.That(convertedBackValues.Length, Is.EqualTo(values.Length));
|
Assert.That(convertedBackValues, Has.Length.EqualTo(values.Length));
|
||||||
for (var i = 0; i < values.Length; i++)
|
for (var i = 0; i < values.Length; i++)
|
||||||
{
|
{
|
||||||
Assert.That(convertedBackValues[i], Is.EqualTo(values[i]));
|
Assert.That(convertedBackValues[i], Is.EqualTo(values[i]));
|
||||||
|
|
|
@ -31,7 +31,7 @@ class ElementExtensionsTests : BaseMarkupTestFixture<Label>
|
||||||
var effect1 = new NullEffect();
|
var effect1 = new NullEffect();
|
||||||
Bindable.Effects(effect1);
|
Bindable.Effects(effect1);
|
||||||
|
|
||||||
Assert.That(Bindable.Effects.Count, Is.EqualTo(1));
|
Assert.That(Bindable.Effects, Has.Count.EqualTo(1));
|
||||||
Assert.That(Bindable.Effects.Contains(effect1));
|
Assert.That(Bindable.Effects.Contains(effect1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,12 +41,12 @@ class ElementExtensionsTests : BaseMarkupTestFixture<Label>
|
||||||
Bindable.Effects.Clear();
|
Bindable.Effects.Clear();
|
||||||
Assume.That(Bindable.Effects.Count, Is.EqualTo(0));
|
Assume.That(Bindable.Effects.Count, Is.EqualTo(0));
|
||||||
|
|
||||||
NullEffect effect1 = new NullEffect(), effect2 = new NullEffect();
|
NullEffect effect1 = new(), effect2 = new();
|
||||||
Bindable.Effects(effect1, effect2);
|
Bindable.Effects(effect1, effect2);
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(Bindable.Effects.Count, Is.EqualTo(2));
|
Assert.That(Bindable.Effects, Has.Count.EqualTo(2));
|
||||||
Assert.That(Bindable.Effects.Contains(effect1));
|
Assert.That(Bindable.Effects.Contains(effect1));
|
||||||
Assert.That(Bindable.Effects.Contains(effect2));
|
Assert.That(Bindable.Effects.Contains(effect2));
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,21 +30,21 @@ class FuncConverterTests : BaseMarkupTestFixture
|
||||||
(text, addOne, culture) =>
|
(text, addOne, culture) =>
|
||||||
{
|
{
|
||||||
convertBackCulture = culture;
|
convertBackCulture = culture;
|
||||||
return new object[]
|
return
|
||||||
{
|
[
|
||||||
text?.Length > 0 ? text[0] : '\0',
|
text?.Length > 0 ? text[0] : '\0',
|
||||||
(text?.Length ?? 0) - (addOne ? 1 : 0)
|
(text?.Length ?? 0) - (addOne ? 1 : 0)
|
||||||
};
|
];
|
||||||
})
|
})
|
||||||
.AssertConvert(new object[] { 'a', 2 }, true, "aaa", twoWay: true, culture: expectedCulture)
|
.AssertConvert(['a', 2], true, "aaa", twoWay: true, culture: expectedCulture)
|
||||||
.AssertConvert(new object[] { 'b', 4 }, false, "bbbb", twoWay: true, culture: expectedCulture);
|
.AssertConvert(['b', 4], false, "bbbb", twoWay: true, culture: expectedCulture);
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(convertCulture, Is.EqualTo(expectedCulture));
|
Assert.That(convertCulture, Is.EqualTo(expectedCulture));
|
||||||
Assert.That(convertBackCulture, 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(['a', 2], null, null, CultureInfo.InvariantCulture), Is.EqualTo("aa"));
|
||||||
});
|
});
|
||||||
|
|
||||||
var backValues = converter.ConvertBack(null, null, null, CultureInfo.InvariantCulture);
|
var backValues = converter.ConvertBack(null, null, null, CultureInfo.InvariantCulture);
|
||||||
|
@ -74,15 +74,16 @@ class FuncConverterTests : BaseMarkupTestFixture
|
||||||
},
|
},
|
||||||
(text, addOne) =>
|
(text, addOne) =>
|
||||||
{
|
{
|
||||||
return new object[] {
|
return
|
||||||
text?.Length > 0 ? text[0] : '\0',
|
[
|
||||||
(text?.Length ?? 0) - (addOne ? 1 : 0)
|
text?.Length > 0 ? text[0] : '\0',
|
||||||
};
|
(text?.Length ?? 0) - (addOne ? 1 : 0)
|
||||||
|
];
|
||||||
})
|
})
|
||||||
.AssertConvert(new object[] { 'a', 2 }, true, "aaa", twoWay: true)
|
.AssertConvert(['a', 2], true, "aaa", twoWay: true)
|
||||||
.AssertConvert(new object[] { 'b', 4 }, false, "bbbb", twoWay: true);
|
.AssertConvert(['b', 4], false, "bbbb", twoWay: true);
|
||||||
|
|
||||||
Assert.That(converter.Convert(new object[] { 'a', 2 }, null, null, CultureInfo.InvariantCulture), Is.EqualTo("aa"));
|
Assert.That(converter.Convert(['a', 2], null, null, CultureInfo.InvariantCulture), Is.EqualTo("aa"));
|
||||||
var backValues = converter.ConvertBack(null, null, null, CultureInfo.InvariantCulture);
|
var backValues = converter.ConvertBack(null, null, null, CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
|
@ -105,15 +106,16 @@ class FuncConverterTests : BaseMarkupTestFixture
|
||||||
},
|
},
|
||||||
(text) =>
|
(text) =>
|
||||||
{
|
{
|
||||||
return new object[] {
|
return
|
||||||
text?.Length > 0 ? text[0] : '\0',
|
[
|
||||||
text?.Length ?? 0
|
text?.Length > 0 ? text[0] : '\0',
|
||||||
};
|
text?.Length ?? 0
|
||||||
|
];
|
||||||
})
|
})
|
||||||
.AssertConvert(new object[] { 'a', 2 }, true, "aa", twoWay: true)
|
.AssertConvert(['a', 2], true, "aa", twoWay: true)
|
||||||
.AssertConvert(new object[] { 'b', 4 }, false, "bbbb", twoWay: true);
|
.AssertConvert(['b', 4], false, "bbbb", twoWay: true);
|
||||||
|
|
||||||
Assert.That(converter.Convert(new object[] { 'a', 2 }, null, null, CultureInfo.InvariantCulture), Is.EqualTo("aa"));
|
Assert.That(converter.Convert(['a', 2], null, null, CultureInfo.InvariantCulture), Is.EqualTo("aa"));
|
||||||
|
|
||||||
var backValues = converter.ConvertBack(null, null, null, CultureInfo.InvariantCulture);
|
var backValues = converter.ConvertBack(null, null, null, CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
||||||
|
|
||||||
gestureElement.BindClickGesture(nameof(ViewModel.SetGuidCommand));
|
gestureElement.BindClickGesture(nameof(ViewModel.SetGuidCommand));
|
||||||
|
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||||
BindingHelpers.AssertBindingExists((ClickGestureRecognizer)gestureElement.GestureRecognizers[0], ClickGestureRecognizer.CommandProperty, nameof(ViewModel.SetGuidCommand));
|
BindingHelpers.AssertBindingExists((ClickGestureRecognizer)gestureElement.GestureRecognizers[0], ClickGestureRecognizer.CommandProperty, nameof(ViewModel.SetGuidCommand));
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||||
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
||||||
});
|
});
|
||||||
|
@ -50,7 +50,7 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
||||||
|
|
||||||
gestureElement.BindTapGesture(nameof(ViewModel.SetGuidCommand));
|
gestureElement.BindTapGesture(nameof(ViewModel.SetGuidCommand));
|
||||||
|
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||||
BindingHelpers.AssertBindingExists((TapGestureRecognizer)gestureElement.GestureRecognizers[0], TapGestureRecognizer.CommandProperty, nameof(ViewModel.SetGuidCommand));
|
BindingHelpers.AssertBindingExists((TapGestureRecognizer)gestureElement.GestureRecognizers[0], TapGestureRecognizer.CommandProperty, nameof(ViewModel.SetGuidCommand));
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||||
Assert.That(((TapGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
Assert.That(((TapGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
||||||
});
|
});
|
||||||
|
@ -91,7 +91,7 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(clicks, Is.GreaterThan(0));
|
Assert.That(clicks, Is.GreaterThan(0));
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||||
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
||||||
});
|
});
|
||||||
|
@ -111,7 +111,7 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(taps, Is.GreaterThan(0));
|
Assert.That(taps, Is.GreaterThan(0));
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||||
Assert.That(((TapGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
Assert.That(((TapGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
||||||
});
|
});
|
||||||
|
@ -124,7 +124,7 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
||||||
|
|
||||||
gestureElement.BindSwipeGesture(nameof(ViewModel.SetGuidCommand));
|
gestureElement.BindSwipeGesture(nameof(ViewModel.SetGuidCommand));
|
||||||
|
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||||
BindingHelpers.AssertBindingExists((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0], SwipeGestureRecognizer.CommandProperty, nameof(ViewModel.SetGuidCommand));
|
BindingHelpers.AssertBindingExists((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0], SwipeGestureRecognizer.CommandProperty, nameof(ViewModel.SetGuidCommand));
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
||||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
||||||
|
@ -167,7 +167,7 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(panCount, Is.EqualTo(1));
|
Assert.That(panCount, Is.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<PanGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<PanGestureRecognizer>());
|
||||||
Assert.That(((PanGestureRecognizer)gestureElement.GestureRecognizers[0]).TouchPoints, Is.EqualTo(touchPoints));
|
Assert.That(((PanGestureRecognizer)gestureElement.GestureRecognizers[0]).TouchPoints, Is.EqualTo(touchPoints));
|
||||||
});
|
});
|
||||||
|
@ -188,7 +188,7 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(pinchCount, Is.EqualTo(1));
|
Assert.That(pinchCount, Is.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(pinchCount));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(pinchCount));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<PinchGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<PinchGestureRecognizer>());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(swipeCount, Is.EqualTo(1));
|
Assert.That(swipeCount, Is.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
||||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
||||||
|
@ -229,7 +229,7 @@ class GesturesExtensionsTests<TGestureElement> : BaseMarkupTestFixture where TGe
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(2));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(2));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<PanGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<PanGestureRecognizer>());
|
||||||
Assert.That(gestureElement.GestureRecognizers[1], Is.InstanceOf<SwipeGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[1], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||||
});
|
});
|
||||||
|
@ -258,7 +258,7 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -278,15 +278,15 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
|
|
||||||
gestureElement.BindClickGesture(
|
gestureElement.BindClickGesture(
|
||||||
static (ViewModel vm) => vm.NestedCommand.SetGuidCommand,
|
static (ViewModel vm) => vm.NestedCommand.SetGuidCommand,
|
||||||
new (Func<ViewModel, object?>, string)[]
|
[
|
||||||
{
|
(vm => vm, nameof(ViewModel.NestedCommand)),
|
||||||
(vm => vm, nameof(ViewModel.NestedCommand)), (vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.SetGuidCommand)),
|
(vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.SetGuidCommand))
|
||||||
},
|
],
|
||||||
mode: BindingMode.OneTime);
|
mode: BindingMode.OneTime);
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||||
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
||||||
});
|
});
|
||||||
|
@ -338,22 +338,23 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
object parameterSource = gestureElement.BindingContext;
|
object parameterSource = gestureElement.BindingContext;
|
||||||
|
|
||||||
gestureElement.BindClickGesture(
|
gestureElement.BindClickGesture(
|
||||||
static (ViewModel vm) => vm.NestedCommand.SetGuidCommand,
|
getter: static (ViewModel vm) => vm.NestedCommand.SetGuidCommand,
|
||||||
new (Func<ViewModel, object?>, string)[]
|
handlers: new (Func<ViewModel, object?>, string)[]
|
||||||
{
|
{
|
||||||
(vm => vm, nameof(ViewModel.NestedCommand)), (vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.SetGuidCommand)),
|
(vm => vm, nameof(ViewModel.NestedCommand)), (vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.SetGuidCommand))
|
||||||
},
|
},
|
||||||
commandBindingMode: BindingMode.OneTime,
|
commandBindingMode: BindingMode.OneTime,
|
||||||
parameterGetter: static (ViewModel vm) => vm.NestedCommand.Id,
|
parameterGetter: static (ViewModel vm) => vm.NestedCommand.Id,
|
||||||
parameterHandlers: new (Func<ViewModel, object?>, string)[]
|
parameterHandlers:
|
||||||
{
|
[
|
||||||
(vm => vm, nameof(ViewModel.NestedCommand)), (vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.Id)),
|
(vm => vm, nameof(ViewModel.NestedCommand)),
|
||||||
},
|
(vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.Id))
|
||||||
|
],
|
||||||
numberOfClicksRequired: numberOfClicks);
|
numberOfClicksRequired: numberOfClicks);
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<ClickGestureRecognizer>());
|
||||||
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
Assert.That(((ClickGestureRecognizer)gestureElement.GestureRecognizers[0]).NumberOfClicksRequired, Is.EqualTo(numberOfClicks));
|
||||||
});
|
});
|
||||||
|
@ -376,7 +377,7 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -392,16 +393,17 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
};
|
};
|
||||||
|
|
||||||
gestureElement.BindTapGesture(
|
gestureElement.BindTapGesture(
|
||||||
static (ViewModel vm) => vm.NestedCommand.SetGuidCommand,
|
getter: static (ViewModel vm) => vm.NestedCommand.SetGuidCommand,
|
||||||
new (Func<ViewModel, object?>, string)[]
|
handlers:
|
||||||
{
|
[
|
||||||
(vm => vm, nameof(ViewModel.NestedCommand)), (vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.SetGuidCommand)),
|
(vm => vm, nameof(ViewModel.NestedCommand)),
|
||||||
},
|
(vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.SetGuidCommand))
|
||||||
|
],
|
||||||
mode: BindingMode.OneTime);
|
mode: BindingMode.OneTime);
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -436,7 +438,7 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(viewModel.Id, Is.EqualTo(guid));
|
Assert.That(viewModel.Id, Is.EqualTo(guid));
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||||
Assert.That(tapGestureRecognizer.NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
Assert.That(tapGestureRecognizer.NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
||||||
});
|
});
|
||||||
|
@ -458,24 +460,26 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
object parameterSource = gestureElement.BindingContext;
|
object parameterSource = gestureElement.BindingContext;
|
||||||
|
|
||||||
gestureElement.BindTapGesture(
|
gestureElement.BindTapGesture(
|
||||||
static (ViewModel vm) => vm.NestedCommand.SetGuidCommand,
|
getter: static (ViewModel vm) => vm.NestedCommand.SetGuidCommand,
|
||||||
new (Func<ViewModel, object?>, string)[]
|
handlers:
|
||||||
{
|
[
|
||||||
(vm => vm, nameof(ViewModel.NestedCommand)), (vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.SetGuidCommand)),
|
(vm => vm, nameof(ViewModel.NestedCommand)),
|
||||||
},
|
(vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.SetGuidCommand))
|
||||||
|
],
|
||||||
commandBindingMode: BindingMode.OneTime,
|
commandBindingMode: BindingMode.OneTime,
|
||||||
parameterGetter: static (ViewModel vm) => vm.NestedCommand.Id,
|
parameterGetter: static (ViewModel vm) => vm.NestedCommand.Id,
|
||||||
parameterHandlers: new (Func<ViewModel, object?>, string)[]
|
parameterHandlers:
|
||||||
{
|
[
|
||||||
(vm => vm, nameof(ViewModel.NestedCommand)), (vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.Id)),
|
(vm => vm, nameof(ViewModel.NestedCommand)),
|
||||||
},
|
(vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.Id))
|
||||||
|
],
|
||||||
numberOfTapsRequired: numberOfTaps);
|
numberOfTapsRequired: numberOfTaps);
|
||||||
|
|
||||||
var tapGestureRecognizer = (TapGestureRecognizer)gestureElement.GestureRecognizers[0];
|
var tapGestureRecognizer = (TapGestureRecognizer)gestureElement.GestureRecognizers[0];
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<TapGestureRecognizer>());
|
||||||
Assert.That(tapGestureRecognizer.NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
Assert.That(tapGestureRecognizer.NumberOfTapsRequired, Is.EqualTo(numberOfTaps));
|
||||||
});
|
});
|
||||||
|
@ -494,7 +498,7 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
|
|
||||||
gestureElement.BindSwipeGesture(static (ViewModel vm) => vm.SetGuidCommand);
|
gestureElement.BindSwipeGesture(static (ViewModel vm) => vm.SetGuidCommand);
|
||||||
|
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||||
BindingHelpers.AssertTypedBindingExists((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0], SwipeGestureRecognizer.CommandProperty, BindingMode.Default, gestureElement.BindingContext);
|
BindingHelpers.AssertTypedBindingExists((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0], SwipeGestureRecognizer.CommandProperty, BindingMode.Default, gestureElement.BindingContext);
|
||||||
}
|
}
|
||||||
|
@ -508,16 +512,17 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
};
|
};
|
||||||
|
|
||||||
gestureElement.BindSwipeGesture(
|
gestureElement.BindSwipeGesture(
|
||||||
static (ViewModel vm) => vm.NestedCommand.SetGuidCommand,
|
getter: static (ViewModel vm) => vm.NestedCommand.SetGuidCommand,
|
||||||
new (Func<ViewModel, object?>, string)[]
|
handlers:
|
||||||
{
|
[
|
||||||
(vm => vm, nameof(ViewModel.NestedCommand)), (vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.SetGuidCommand)),
|
(vm => vm, nameof(ViewModel.NestedCommand)),
|
||||||
},
|
(vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.SetGuidCommand))
|
||||||
|
],
|
||||||
mode: BindingMode.OneTime);
|
mode: BindingMode.OneTime);
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -556,7 +561,7 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(viewModel.Id, Is.EqualTo(guid));
|
Assert.That(viewModel.Id, Is.EqualTo(guid));
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
||||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
||||||
|
@ -578,23 +583,25 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
};
|
};
|
||||||
|
|
||||||
gestureElement.BindSwipeGesture(
|
gestureElement.BindSwipeGesture(
|
||||||
static (ViewModel vm) => vm.NestedCommand.SetGuidCommand,
|
getter: static (ViewModel vm) => vm.NestedCommand.SetGuidCommand,
|
||||||
new (Func<ViewModel, object?>, string)[]
|
handlers:
|
||||||
{
|
[
|
||||||
(vm => vm, nameof(ViewModel.NestedCommand)), (vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.SetGuidCommand)),
|
(vm => vm, nameof(ViewModel.NestedCommand)),
|
||||||
},
|
(vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.SetGuidCommand))
|
||||||
|
],
|
||||||
commandBindingMode: BindingMode.OneTime,
|
commandBindingMode: BindingMode.OneTime,
|
||||||
parameterGetter: static (ViewModel vm) => vm.NestedCommand.Id,
|
parameterGetter: static (ViewModel vm) => vm.NestedCommand.Id,
|
||||||
parameterHandlers: new (Func<ViewModel, object?>, string)[]
|
parameterHandlers:
|
||||||
{
|
[
|
||||||
(vm => vm, nameof(ViewModel.NestedCommand)), (vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.Id)),
|
(vm => vm, nameof(ViewModel.NestedCommand)),
|
||||||
},
|
(vm => vm.NestedCommand, nameof(ViewModel.NestedCommand.Id))
|
||||||
|
],
|
||||||
direction: direction,
|
direction: direction,
|
||||||
threshold: threshold);
|
threshold: threshold);
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(1));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(1));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Direction, Is.EqualTo(direction));
|
||||||
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
Assert.That(((SwipeGestureRecognizer)gestureElement.GestureRecognizers[0]).Threshold, Is.EqualTo(threshold));
|
||||||
|
@ -617,7 +624,7 @@ class GesturesExtensionsTypedBindingsTests<TGestureElement> : BaseMarkupTestFixt
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(gestureElement.GestureRecognizers.Count, Is.EqualTo(3));
|
Assert.That(gestureElement.GestureRecognizers, Has.Count.EqualTo(3));
|
||||||
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[0], Is.InstanceOf<SwipeGestureRecognizer>());
|
||||||
Assert.That(gestureElement.GestureRecognizers[1], Is.InstanceOf<TapGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[1], Is.InstanceOf<TapGestureRecognizer>());
|
||||||
Assert.That(gestureElement.GestureRecognizers[2], Is.InstanceOf<ClickGestureRecognizer>());
|
Assert.That(gestureElement.GestureRecognizers[2], Is.InstanceOf<ClickGestureRecognizer>());
|
||||||
|
|
|
@ -23,7 +23,7 @@ class GridRowsColumns : BaseMarkupTestFixture
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(grid.RowDefinitions.Count, Is.EqualTo(4));
|
Assert.That(grid.RowDefinitions, Has.Count.EqualTo(4));
|
||||||
Assert.That(grid.RowDefinitions[0]?.Height, Is.EqualTo(GridLength.Auto));
|
Assert.That(grid.RowDefinitions[0]?.Height, Is.EqualTo(GridLength.Auto));
|
||||||
Assert.That(grid.RowDefinitions[1]?.Height, Is.EqualTo(GridLength.Star));
|
Assert.That(grid.RowDefinitions[1]?.Height, Is.EqualTo(GridLength.Star));
|
||||||
Assert.That(grid.RowDefinitions[2]?.Height, Is.EqualTo(starsLength));
|
Assert.That(grid.RowDefinitions[2]?.Height, Is.EqualTo(starsLength));
|
||||||
|
@ -46,7 +46,7 @@ class GridRowsColumns : BaseMarkupTestFixture
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(grid.RowDefinitions.Count, Is.EqualTo(4));
|
Assert.That(grid.RowDefinitions, Has.Count.EqualTo(4));
|
||||||
Assert.That(grid.RowDefinitions[0]?.Height, Is.EqualTo(GridLength.Auto));
|
Assert.That(grid.RowDefinitions[0]?.Height, Is.EqualTo(GridLength.Auto));
|
||||||
Assert.That(grid.RowDefinitions[1]?.Height, Is.EqualTo(GridLength.Star));
|
Assert.That(grid.RowDefinitions[1]?.Height, Is.EqualTo(GridLength.Star));
|
||||||
Assert.That(grid.RowDefinitions[2]?.Height, Is.EqualTo(starsLength));
|
Assert.That(grid.RowDefinitions[2]?.Height, Is.EqualTo(starsLength));
|
||||||
|
@ -73,7 +73,7 @@ class GridRowsColumns : BaseMarkupTestFixture
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(grid.ColumnDefinitions.Count, Is.EqualTo(5));
|
Assert.That(grid.ColumnDefinitions, Has.Count.EqualTo(5));
|
||||||
Assert.That(grid.ColumnDefinitions[0]?.Width, Is.EqualTo(GridLength.Auto));
|
Assert.That(grid.ColumnDefinitions[0]?.Width, Is.EqualTo(GridLength.Auto));
|
||||||
Assert.That(grid.ColumnDefinitions[1]?.Width, Is.EqualTo(GridLength.Star));
|
Assert.That(grid.ColumnDefinitions[1]?.Width, Is.EqualTo(GridLength.Star));
|
||||||
Assert.That(grid.ColumnDefinitions[2]?.Width, Is.EqualTo(starsLength));
|
Assert.That(grid.ColumnDefinitions[2]?.Width, Is.EqualTo(starsLength));
|
||||||
|
@ -98,7 +98,7 @@ class GridRowsColumns : BaseMarkupTestFixture
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(grid.ColumnDefinitions.Count, Is.EqualTo(5));
|
Assert.That(grid.ColumnDefinitions, Has.Count.EqualTo(5));
|
||||||
Assert.That(grid.ColumnDefinitions[0]?.Width, Is.EqualTo(GridLength.Auto));
|
Assert.That(grid.ColumnDefinitions[0]?.Width, Is.EqualTo(GridLength.Auto));
|
||||||
Assert.That(grid.ColumnDefinitions[1]?.Width, Is.EqualTo(GridLength.Star));
|
Assert.That(grid.ColumnDefinitions[1]?.Width, Is.EqualTo(GridLength.Star));
|
||||||
Assert.That(grid.ColumnDefinitions[2]?.Width, Is.EqualTo(starsLength));
|
Assert.That(grid.ColumnDefinitions[2]?.Width, Is.EqualTo(starsLength));
|
||||||
|
|
|
@ -12,7 +12,7 @@ class SemanticPropertiesExtensionsTests : BaseMarkupTestFixture<Label>
|
||||||
const string description = "This label does XYZ";
|
const string description = "This label does XYZ";
|
||||||
Bindable.SemanticDescription(description);
|
Bindable.SemanticDescription(description);
|
||||||
|
|
||||||
Assert.That(SemanticProperties.GetDescription(Bindable) == description);
|
Assert.That(SemanticProperties.GetDescription(Bindable), Is.EqualTo(description));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -21,7 +21,7 @@ class SemanticPropertiesExtensionsTests : BaseMarkupTestFixture<Label>
|
||||||
const SemanticHeadingLevel headingLevel = SemanticHeadingLevel.Level5;
|
const SemanticHeadingLevel headingLevel = SemanticHeadingLevel.Level5;
|
||||||
Bindable.SemanticHeadingLevel(headingLevel);
|
Bindable.SemanticHeadingLevel(headingLevel);
|
||||||
|
|
||||||
Assert.That(SemanticProperties.GetHeadingLevel(Bindable) == headingLevel);
|
Assert.That(SemanticProperties.GetHeadingLevel(Bindable), Is.EqualTo(headingLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -30,6 +30,6 @@ class SemanticPropertiesExtensionsTests : BaseMarkupTestFixture<Label>
|
||||||
const string hint = "This label does XYZ";
|
const string hint = "This label does XYZ";
|
||||||
Bindable.SemanticHint(hint);
|
Bindable.SemanticHint(hint);
|
||||||
|
|
||||||
Assert.That(SemanticProperties.GetHint(Bindable) == hint);
|
Assert.That(SemanticProperties.GetHint(Bindable), Is.EqualTo(hint));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -50,7 +50,7 @@ class StyleTests : BaseMarkupTestFixture
|
||||||
var style = new Style<Label>(Label.TextColorProperty, Colors.Red);
|
var style = new Style<Label>(Label.TextColorProperty, Colors.Red);
|
||||||
Style formsStyle = style;
|
Style formsStyle = style;
|
||||||
|
|
||||||
Assert.That(formsStyle.Setters.Count, Is.EqualTo(1));
|
Assert.That(formsStyle.Setters, Has.Count.EqualTo(1));
|
||||||
|
|
||||||
var setter = formsStyle.Setters[0];
|
var setter = formsStyle.Setters[0];
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class StyleTests : BaseMarkupTestFixture
|
||||||
(Label.TranslationXProperty, 8.0));
|
(Label.TranslationXProperty, 8.0));
|
||||||
Style formsStyle = style;
|
Style formsStyle = style;
|
||||||
|
|
||||||
Assert.That(formsStyle.Setters.Count, Is.EqualTo(2));
|
Assert.That(formsStyle.Setters, Has.Count.EqualTo(2));
|
||||||
|
|
||||||
var setter1 = formsStyle.Setters[0];
|
var setter1 = formsStyle.Setters[0];
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class StyleTests : BaseMarkupTestFixture
|
||||||
|
|
||||||
style.Add(Label.TextColorProperty, Colors.Red);
|
style.Add(Label.TextColorProperty, Colors.Red);
|
||||||
|
|
||||||
Assert.That(formsStyle.Setters.Count, Is.EqualTo(1));
|
Assert.That(formsStyle.Setters, Has.Count.EqualTo(1));
|
||||||
|
|
||||||
var setter = formsStyle.Setters[0];
|
var setter = formsStyle.Setters[0];
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class StyleTests : BaseMarkupTestFixture
|
||||||
(Label.TextColorProperty, Colors.Red),
|
(Label.TextColorProperty, Colors.Red),
|
||||||
(Label.TranslationXProperty, 8.0));
|
(Label.TranslationXProperty, 8.0));
|
||||||
|
|
||||||
Assert.That(formsStyle.Setters.Count, Is.EqualTo(2));
|
Assert.That(formsStyle.Setters, Has.Count.EqualTo(2));
|
||||||
|
|
||||||
var setter1 = formsStyle.Setters[0];
|
var setter1 = formsStyle.Setters[0];
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ class StyleTests : BaseMarkupTestFixture
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(formsStyle.Behaviors.Count, Is.EqualTo(1));
|
Assert.That(formsStyle.Behaviors, Has.Count.EqualTo(1));
|
||||||
Assert.That(ReferenceEquals(formsStyle.Behaviors[0], behavior));
|
Assert.That(ReferenceEquals(formsStyle.Behaviors[0], behavior));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ class StyleTests : BaseMarkupTestFixture
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(formsStyle.Behaviors.Count, Is.EqualTo(2));
|
Assert.That(formsStyle.Behaviors, Has.Count.EqualTo(2));
|
||||||
Assert.That(ReferenceEquals(formsStyle.Behaviors[0], behavior1));
|
Assert.That(ReferenceEquals(formsStyle.Behaviors[0], behavior1));
|
||||||
Assert.That(ReferenceEquals(formsStyle.Behaviors[1], behavior2));
|
Assert.That(ReferenceEquals(formsStyle.Behaviors[1], behavior2));
|
||||||
});
|
});
|
||||||
|
@ -213,7 +213,7 @@ class StyleTests : BaseMarkupTestFixture
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(formsStyle.Triggers.Count, Is.EqualTo(1));
|
Assert.That(formsStyle.Triggers, Has.Count.EqualTo(1));
|
||||||
Assert.That(ReferenceEquals(formsStyle.Triggers[0], trigger));
|
Assert.That(ReferenceEquals(formsStyle.Triggers[0], trigger));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ class StyleTests : BaseMarkupTestFixture
|
||||||
|
|
||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(formsStyle.Triggers.Count, Is.EqualTo(2));
|
Assert.That(formsStyle.Triggers, Has.Count.EqualTo(2));
|
||||||
Assert.That(ReferenceEquals(formsStyle.Triggers[0], trigger1));
|
Assert.That(ReferenceEquals(formsStyle.Triggers[0], trigger1));
|
||||||
Assert.That(ReferenceEquals(formsStyle.Triggers[1], trigger2));
|
Assert.That(ReferenceEquals(formsStyle.Triggers[1], trigger2));
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,10 +42,9 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
||||||
new Button()
|
new Button()
|
||||||
.BindCommand<Button, ViewModel, object?, Color>(
|
.BindCommand<Button, ViewModel, object?, Color>(
|
||||||
(ViewModel vm) => vm.Command,
|
(ViewModel vm) => vm.Command,
|
||||||
new (Func<ViewModel, object?>, string)[]
|
[
|
||||||
{
|
(vm => vm, nameof(ViewModel.Command))
|
||||||
(vm => vm, nameof(ViewModel.Command)),
|
],
|
||||||
},
|
|
||||||
parameterGetter: _ => Colors.Black);
|
parameterGetter: _ => Colors.Black);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -327,12 +326,11 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
||||||
entry.BindingContext = viewmodel;
|
entry.BindingContext = viewmodel;
|
||||||
entry.Bind(Entry.TextColorProperty,
|
entry.Bind(Entry.TextColorProperty,
|
||||||
static (NestedViewModel vm) => vm.Model?.Model?.TextColor,
|
static (NestedViewModel vm) => vm.Model?.Model?.TextColor,
|
||||||
new (Func<NestedViewModel, object?>, string)[]
|
[
|
||||||
{
|
|
||||||
(vm => vm, nameof(NestedViewModel.Model)),
|
(vm => vm, nameof(NestedViewModel.Model)),
|
||||||
(vm => vm.Model, nameof(NestedViewModel.Model)),
|
(vm => vm.Model, nameof(NestedViewModel.Model)),
|
||||||
(vm => vm.Model?.Model, nameof(NestedViewModel.Model.TextColor))
|
(vm => vm.Model?.Model, nameof(NestedViewModel.Model.TextColor))
|
||||||
},
|
],
|
||||||
static (NestedViewModel vm, Color? color) =>
|
static (NestedViewModel vm, Color? color) =>
|
||||||
{
|
{
|
||||||
if (vm.Model?.Model?.TextColor is not null && color is not null)
|
if (vm.Model?.Model?.TextColor is not null && color is not null)
|
||||||
|
@ -346,12 +344,11 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
||||||
{
|
{
|
||||||
entry.Bind(Entry.TextColorProperty,
|
entry.Bind(Entry.TextColorProperty,
|
||||||
static (NestedViewModel vm) => vm.Model?.Model?.TextColor,
|
static (NestedViewModel vm) => vm.Model?.Model?.TextColor,
|
||||||
new (Func<NestedViewModel, object?>, string)[]
|
[
|
||||||
{
|
|
||||||
(vm => vm, nameof(NestedViewModel.Model)),
|
(vm => vm, nameof(NestedViewModel.Model)),
|
||||||
(vm => vm.Model, nameof(NestedViewModel.Model)),
|
(vm => vm.Model, nameof(NestedViewModel.Model)),
|
||||||
(vm => vm.Model?.Model, nameof(NestedViewModel.Model.TextColor))
|
(vm => vm.Model?.Model, nameof(NestedViewModel.Model.TextColor))
|
||||||
},
|
],
|
||||||
static (NestedViewModel vm, Color? color) =>
|
static (NestedViewModel vm, Color? color) =>
|
||||||
{
|
{
|
||||||
if (vm.Model?.Model?.TextColor is not null && color is not null)
|
if (vm.Model?.Model?.TextColor is not null && color is not null)
|
||||||
|
@ -405,12 +402,11 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
||||||
label.BindingContext = viewmodel;
|
label.BindingContext = viewmodel;
|
||||||
label.Bind<Label, NestedViewModel, Color?, string>(Label.TextProperty,
|
label.Bind<Label, NestedViewModel, Color?, string>(Label.TextProperty,
|
||||||
static (NestedViewModel vm) => vm.Model?.Model?.TextColor,
|
static (NestedViewModel vm) => vm.Model?.Model?.TextColor,
|
||||||
new (Func<NestedViewModel, object?>, string)[]
|
[
|
||||||
{
|
|
||||||
(vm => vm, nameof(NestedViewModel.Model)),
|
(vm => vm, nameof(NestedViewModel.Model)),
|
||||||
(vm => vm.Model, nameof(NestedViewModel.Model)),
|
(vm => vm.Model, nameof(NestedViewModel.Model)),
|
||||||
(vm => vm.Model?.Model, nameof(NestedViewModel.Model.TextColor))
|
(vm => vm.Model?.Model, nameof(NestedViewModel.Model.TextColor))
|
||||||
},
|
],
|
||||||
static (NestedViewModel vm, Color? color) =>
|
static (NestedViewModel vm, Color? color) =>
|
||||||
{
|
{
|
||||||
if (vm.Model?.Model?.TextColor is not null && color is not null)
|
if (vm.Model?.Model?.TextColor is not null && color is not null)
|
||||||
|
@ -425,12 +421,11 @@ class TypedBindingExtensionsTests : BaseMarkupTestFixture
|
||||||
{
|
{
|
||||||
label.Bind<Label, NestedViewModel, Color?, string>(Label.TextProperty,
|
label.Bind<Label, NestedViewModel, Color?, string>(Label.TextProperty,
|
||||||
static (NestedViewModel vm) => vm.Model?.Model?.TextColor,
|
static (NestedViewModel vm) => vm.Model?.Model?.TextColor,
|
||||||
new (Func<NestedViewModel, object?>, string)[]
|
[
|
||||||
{
|
|
||||||
(vm => vm, nameof(NestedViewModel.Model)),
|
(vm => vm, nameof(NestedViewModel.Model)),
|
||||||
(vm => vm.Model, nameof(NestedViewModel.Model)),
|
(vm => vm.Model, nameof(NestedViewModel.Model)),
|
||||||
(vm => vm.Model?.Model, nameof(NestedViewModel.Model.TextColor))
|
(vm => vm.Model?.Model, nameof(NestedViewModel.Model.TextColor))
|
||||||
},
|
],
|
||||||
static (NestedViewModel vm, Color? color) =>
|
static (NestedViewModel vm, Color? color) =>
|
||||||
{
|
{
|
||||||
if (vm.Model?.Model?.TextColor is not null && color is not null)
|
if (vm.Model?.Model?.TextColor is not null && color is not null)
|
||||||
|
|
|
@ -11,7 +11,7 @@ class UnitExpressionSearch : ExpressionVisitor, IExpressionSearch
|
||||||
|
|
||||||
public List<T?> FindObjects<T>(Expression expression) where T : class
|
public List<T?> FindObjects<T>(Expression expression) where T : class
|
||||||
{
|
{
|
||||||
results = new List<object>();
|
results = [];
|
||||||
targeType = typeof(T);
|
targeType = typeof(T);
|
||||||
Visit(expression);
|
Visit(expression);
|
||||||
return results.Select(o => o as T).ToList();
|
return results.Select(o => o as T).ToList();
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class FuncMultiConverter<TSource1, TSource2, TDest> : FuncMultiConverter<
|
||||||
{
|
{
|
||||||
static T? To<T>(object? value) => value != null ? (T)value : default;
|
static T? To<T>(object? value) => value != null ? (T)value : default;
|
||||||
|
|
||||||
static object?[] ToObjects(ValueTuple<TSource1, TSource2> values) => new object?[] { values.Item1, values.Item2 };
|
static object?[] ToObjects(ValueTuple<TSource1, TSource2> values) => [values.Item1, values.Item2];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of <see cref="FuncMultiConverter{TSource1, TSource2, TDest}" />.
|
/// Initializes a new instance of <see cref="FuncMultiConverter{TSource1, TSource2, TDest}" />.
|
||||||
|
@ -157,7 +157,7 @@ public class FuncMultiConverter<TSource1, TSource2, TSource3, TDest> : FuncMulti
|
||||||
{
|
{
|
||||||
static T? To<T>(object? value) => value != null ? (T)value : default;
|
static T? To<T>(object? value) => value != null ? (T)value : default;
|
||||||
|
|
||||||
static object?[] ToObjects(ValueTuple<TSource1, TSource2, TSource3> values) => new object?[] { values.Item1, values.Item2, values.Item3 };
|
static object?[] ToObjects(ValueTuple<TSource1, TSource2, TSource3> values) => [values.Item1, values.Item2, values.Item3];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of <see cref="FuncMultiConverter{TSource1, TSource2, TSource3, TDest}" />.
|
/// Initializes a new instance of <see cref="FuncMultiConverter{TSource1, TSource2, TSource3, TDest}" />.
|
||||||
|
@ -189,7 +189,7 @@ public class FuncMultiConverter<TSource1, TSource2, TSource3, TSource4, TDest> :
|
||||||
{
|
{
|
||||||
static T? To<T>(object? value) => value != null ? (T)value : default;
|
static T? To<T>(object? value) => value != null ? (T)value : default;
|
||||||
|
|
||||||
static object?[] ToObjects(ValueTuple<TSource1, TSource2, TSource3, TSource4> values) => new object?[] { values.Item1, values.Item2, values.Item3, values.Item4 };
|
static object?[] ToObjects(ValueTuple<TSource1, TSource2, TSource3, TSource4> values) => [values.Item1, values.Item2, values.Item3, values.Item4];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of <see cref="FuncMultiConverter{TSource1, TSource2, TSource3, TSource4, TDest}" />.
|
/// Initializes a new instance of <see cref="FuncMultiConverter{TSource1, TSource2, TSource3, TSource4, TDest}" />.
|
||||||
|
@ -220,7 +220,7 @@ public class FuncMultiConverterWithParam<TSource1, TSource2, TDest, TParam> : Fu
|
||||||
{
|
{
|
||||||
static T? To<T>(object? value) => value != null ? (T)value : default;
|
static T? To<T>(object? value) => value != null ? (T)value : default;
|
||||||
|
|
||||||
static object?[] ToObjects(ValueTuple<TSource1, TSource2> values) => new object?[] { values.Item1, values.Item2 };
|
static object?[] ToObjects(ValueTuple<TSource1, TSource2> values) => [values.Item1, values.Item2];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of <see cref="FuncMultiConverter{TSource1, TSource2, TDest, TParam}" />.
|
/// Initializes a new instance of <see cref="FuncMultiConverter{TSource1, TSource2, TDest, TParam}" />.
|
||||||
|
@ -251,7 +251,7 @@ public class FuncMultiConverterWithParam<TSource1, TSource2, TSource3, TDest, TP
|
||||||
{
|
{
|
||||||
static T? To<T>(object value) => value != null ? (T)value : default;
|
static T? To<T>(object value) => value != null ? (T)value : default;
|
||||||
|
|
||||||
static object?[] ToObjects(ValueTuple<TSource1, TSource2, TSource3> values) => new object?[] { values.Item1, values.Item2, values.Item3 };
|
static object?[] ToObjects(ValueTuple<TSource1, TSource2, TSource3> values) => [values.Item1, values.Item2, values.Item3];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of <see cref="FuncMultiConverter{TSource1, TSource2, TSource3, TDest, TParam}" />.
|
/// Initializes a new instance of <see cref="FuncMultiConverter{TSource1, TSource2, TSource3, TDest, TParam}" />.
|
||||||
|
@ -284,7 +284,7 @@ public class FuncMultiConverterWithParam<TSource1, TSource2, TSource3, TSource4,
|
||||||
{
|
{
|
||||||
static T? To<T>(object? value) => value != null ? (T)value : default;
|
static T? To<T>(object? value) => value != null ? (T)value : default;
|
||||||
|
|
||||||
static object?[] ToObjects(ValueTuple<TSource1, TSource2, TSource3, TSource4> values) => new object?[] { values.Item1, values.Item2, values.Item3, values.Item4 };
|
static object?[] ToObjects(ValueTuple<TSource1, TSource2, TSource3, TSource4> values) => [values.Item1, values.Item2, values.Item3, values.Item4];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of <see cref="FuncMultiConverterWithParam{TSource1, TSource2, TSource3, TSource4, TDest, TParam}" />.
|
/// Initializes a new instance of <see cref="FuncMultiConverterWithParam{TSource1, TSource2, TSource3, TSource4, TDest, TParam}" />.
|
||||||
|
|
|
@ -54,7 +54,7 @@ public static partial class GesturesExtensions
|
||||||
return BindClickGesture(
|
return BindClickGesture(
|
||||||
gestureElement,
|
gestureElement,
|
||||||
getterFunc,
|
getterFunc,
|
||||||
new (Func<TCommandBindingContext, object?>, string)[] { ((TCommandBindingContext b) => b, GetMemberName(getter)) },
|
[((TCommandBindingContext b) => b, GetMemberName(getter))],
|
||||||
setter,
|
setter,
|
||||||
source,
|
source,
|
||||||
commandBindingMode,
|
commandBindingMode,
|
||||||
|
@ -167,7 +167,7 @@ public static partial class GesturesExtensions
|
||||||
return BindSwipeGesture(
|
return BindSwipeGesture(
|
||||||
gestureElement,
|
gestureElement,
|
||||||
getterFunc,
|
getterFunc,
|
||||||
new (Func<TCommandBindingContext, object?>, string)[] { ((TCommandBindingContext b) => b, GetMemberName(getter)) },
|
[((TCommandBindingContext b) => b, GetMemberName(getter))],
|
||||||
setter,
|
setter,
|
||||||
source,
|
source,
|
||||||
commandBindingMode,
|
commandBindingMode,
|
||||||
|
@ -280,7 +280,7 @@ public static partial class GesturesExtensions
|
||||||
return BindTapGesture(
|
return BindTapGesture(
|
||||||
gestureElement,
|
gestureElement,
|
||||||
getterFunc,
|
getterFunc,
|
||||||
new (Func<TCommandBindingContext, object?>, string)[] { ((TCommandBindingContext b) => b, GetMemberName(getter)) },
|
[((TCommandBindingContext b) => b, GetMemberName(getter))],
|
||||||
setter,
|
setter,
|
||||||
source,
|
source,
|
||||||
commandBindingMode,
|
commandBindingMode,
|
||||||
|
|
|
@ -191,7 +191,7 @@ public static partial class TypedBindingExtensions
|
||||||
bindable,
|
bindable,
|
||||||
targetProperty,
|
targetProperty,
|
||||||
getterFunc,
|
getterFunc,
|
||||||
new (Func<TBindingContext, object?>, string)[] { ((TBindingContext b) => b, GetMemberName(getter)) },
|
[((TBindingContext b) => b, GetMemberName(getter))],
|
||||||
setter,
|
setter,
|
||||||
mode,
|
mode,
|
||||||
convert,
|
convert,
|
||||||
|
@ -223,7 +223,7 @@ public static partial class TypedBindingExtensions
|
||||||
bindable,
|
bindable,
|
||||||
targetProperty,
|
targetProperty,
|
||||||
getterFunc,
|
getterFunc,
|
||||||
new (Func<TBindingContext, object?>, string)[] { ((TBindingContext b) => b, GetMemberName(getter)) },
|
[((TBindingContext b) => b, GetMemberName(getter))],
|
||||||
setter,
|
setter,
|
||||||
mode,
|
mode,
|
||||||
converter,
|
converter,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче