Resolve Compiler Warnings
This commit is contained in:
Родитель
afe4a3c09c
Коммит
b4314fd3d9
|
@ -15,7 +15,6 @@
|
|||
<Rule Id="SA1008" Action="Warning" />
|
||||
<Rule Id="SA1009" Action="Warning" />
|
||||
<Rule Id="SA1010" Action="Warning" />
|
||||
<Rule Id="SA1011" Action="Warning" />
|
||||
<Rule Id="SA1012" Action="Warning" />
|
||||
<Rule Id="SA1013" Action="Warning" />
|
||||
<Rule Id="SA1014" Action="Warning" />
|
||||
|
|
|
@ -5,75 +5,84 @@ using Xunit;
|
|||
|
||||
namespace Xamarin.CommunityToolkit.UnitTests.Behaviors
|
||||
{
|
||||
public class RequiredStringValidationBehavior_Tests
|
||||
{
|
||||
public RequiredStringValidationBehavior_Tests()
|
||||
=> Device.PlatformServices = new MockPlatformServices();
|
||||
public class RequiredStringValidationBehavior_Tests
|
||||
{
|
||||
public RequiredStringValidationBehavior_Tests()
|
||||
=> Device.PlatformServices = new MockPlatformServices();
|
||||
|
||||
[Fact]
|
||||
public void IsValidTrueWhenBothIsNull_Test()
|
||||
{
|
||||
//arrange
|
||||
var passwordEntry = new Entry();
|
||||
var confirmPasswordEntry = new Entry();
|
||||
var confirmPasswordBehavior = new RequiredStringValidationBehavior();
|
||||
confirmPasswordBehavior.Flags = ValidationFlags.ValidateOnAttaching;
|
||||
//act
|
||||
confirmPasswordBehavior.RequiredString = passwordEntry.Text;
|
||||
confirmPasswordEntry.Behaviors.Add(confirmPasswordBehavior);
|
||||
//assert
|
||||
Assert.True(confirmPasswordBehavior.IsValid);
|
||||
}
|
||||
[Fact]
|
||||
public void IsValidTrueWhenBothIsNull_Test()
|
||||
{
|
||||
// Arrange
|
||||
var passwordEntry = new Entry();
|
||||
var confirmPasswordEntry = new Entry();
|
||||
var confirmPasswordBehavior = new RequiredStringValidationBehavior();
|
||||
confirmPasswordBehavior.Flags = ValidationFlags.ValidateOnAttaching;
|
||||
|
||||
[Fact]
|
||||
public void IsValidFalseWhenOneIsNull_Test()
|
||||
{
|
||||
//arrange
|
||||
var passwordEntry = new Entry();
|
||||
var confirmPasswordEntry = new Entry();
|
||||
var confirmPasswordBehavior = new RequiredStringValidationBehavior();
|
||||
confirmPasswordBehavior.Flags = ValidationFlags.ValidateOnAttaching;
|
||||
//act
|
||||
passwordEntry.Text = "123456";
|
||||
confirmPasswordBehavior.RequiredString = passwordEntry.Text;
|
||||
confirmPasswordEntry.Behaviors.Add(confirmPasswordBehavior);
|
||||
confirmPasswordEntry.Text = null;
|
||||
//assert
|
||||
Assert.False(confirmPasswordBehavior.IsValid);
|
||||
}
|
||||
// Act
|
||||
confirmPasswordBehavior.RequiredString = passwordEntry.Text;
|
||||
confirmPasswordEntry.Behaviors.Add(confirmPasswordBehavior);
|
||||
|
||||
[Fact]
|
||||
public void IsValidTrueWhenEnterSameText_Test()
|
||||
{
|
||||
//arrange
|
||||
var passwordEntry = new Entry();
|
||||
var confirmPasswordEntry = new Entry();
|
||||
var confirmPasswordBehavior = new RequiredStringValidationBehavior();
|
||||
confirmPasswordBehavior.Flags = ValidationFlags.ValidateOnValueChanging;
|
||||
//act
|
||||
passwordEntry.Text = "123456";
|
||||
confirmPasswordBehavior.RequiredString = passwordEntry.Text;
|
||||
confirmPasswordEntry.Behaviors.Add(confirmPasswordBehavior);
|
||||
confirmPasswordEntry.Text = "123456";
|
||||
//assert
|
||||
Assert.True(confirmPasswordBehavior.IsValid);
|
||||
}
|
||||
// Assert
|
||||
Assert.True(confirmPasswordBehavior.IsValid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsValidFalseWhenEnterDifferentText_Test()
|
||||
{
|
||||
//arrange
|
||||
var passwordEntry = new Entry();
|
||||
var confirmPasswordEntry = new Entry();
|
||||
var confirmPasswordBehavior = new RequiredStringValidationBehavior();
|
||||
confirmPasswordBehavior.Flags = ValidationFlags.ValidateOnValueChanging;
|
||||
//act
|
||||
passwordEntry.Text = "123456";
|
||||
confirmPasswordBehavior.RequiredString = passwordEntry.Text;
|
||||
confirmPasswordEntry.Behaviors.Add(confirmPasswordBehavior);
|
||||
confirmPasswordEntry.Text = "1234567";
|
||||
//assert
|
||||
Assert.False(confirmPasswordBehavior.IsValid);
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void IsValidFalseWhenOneIsNull_Test()
|
||||
{
|
||||
// Arrange
|
||||
var passwordEntry = new Entry();
|
||||
var confirmPasswordEntry = new Entry();
|
||||
var confirmPasswordBehavior = new RequiredStringValidationBehavior();
|
||||
confirmPasswordBehavior.Flags = ValidationFlags.ValidateOnAttaching;
|
||||
|
||||
// Act
|
||||
passwordEntry.Text = "123456";
|
||||
confirmPasswordBehavior.RequiredString = passwordEntry.Text;
|
||||
confirmPasswordEntry.Behaviors.Add(confirmPasswordBehavior);
|
||||
|
||||
confirmPasswordEntry.Text = null;
|
||||
|
||||
// Assert
|
||||
Assert.False(confirmPasswordBehavior.IsValid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsValidTrueWhenEnterSameText_Test()
|
||||
{
|
||||
// Arrange
|
||||
var passwordEntry = new Entry();
|
||||
var confirmPasswordEntry = new Entry();
|
||||
var confirmPasswordBehavior = new RequiredStringValidationBehavior();
|
||||
confirmPasswordBehavior.Flags = ValidationFlags.ValidateOnValueChanging;
|
||||
|
||||
// Act
|
||||
passwordEntry.Text = "123456";
|
||||
confirmPasswordBehavior.RequiredString = passwordEntry.Text;
|
||||
confirmPasswordEntry.Behaviors.Add(confirmPasswordBehavior);
|
||||
confirmPasswordEntry.Text = "123456";
|
||||
|
||||
// Assert
|
||||
Assert.True(confirmPasswordBehavior.IsValid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsValidFalseWhenEnterDifferentText_Test()
|
||||
{
|
||||
// Arrange
|
||||
var passwordEntry = new Entry();
|
||||
var confirmPasswordEntry = new Entry();
|
||||
var confirmPasswordBehavior = new RequiredStringValidationBehavior();
|
||||
confirmPasswordBehavior.Flags = ValidationFlags.ValidateOnValueChanging;
|
||||
|
||||
// Act
|
||||
passwordEntry.Text = "123456";
|
||||
confirmPasswordBehavior.RequiredString = passwordEntry.Text;
|
||||
confirmPasswordEntry.Behaviors.Add(confirmPasswordBehavior);
|
||||
confirmPasswordEntry.Text = "1234567";
|
||||
|
||||
// Assert
|
||||
Assert.False(confirmPasswordBehavior.IsValid);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,54 +1,54 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Xamarin.CommunityToolkit.Converters;
|
||||
using Xunit;
|
||||
|
||||
namespace Xamarin.CommunityToolkit.UnitTests.Converters
|
||||
{
|
||||
public class IntToBoolConverter_Tests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(1, true)]
|
||||
[InlineData(0, false)]
|
||||
public void IndexToArrayConverter(int value, bool expectedResult)
|
||||
{
|
||||
var intToBoolConverter = new IntToBoolConverter();
|
||||
public class IntToBoolConverter_Tests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(1, true)]
|
||||
[InlineData(0, false)]
|
||||
public void IndexToArrayConverter(int value, bool expectedResult)
|
||||
{
|
||||
var intToBoolConverter = new IntToBoolConverter();
|
||||
|
||||
var result = intToBoolConverter.Convert(value, typeof(IntToBoolConverter_Tests), null, CultureInfo.CurrentCulture);
|
||||
var result = intToBoolConverter.Convert(value, typeof(IntToBoolConverter_Tests), null, CultureInfo.CurrentCulture);
|
||||
|
||||
Assert.Equal(result, expectedResult);
|
||||
}
|
||||
Assert.Equal(result, expectedResult);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true, 1)]
|
||||
[InlineData(false, 0)]
|
||||
public void IndexToArrayConverterBack(bool value, int expectedResult)
|
||||
{
|
||||
var intToBoolConverter = new IntToBoolConverter();
|
||||
[Theory]
|
||||
[InlineData(true, 1)]
|
||||
[InlineData(false, 0)]
|
||||
public void IndexToArrayConverterBack(bool value, int expectedResult)
|
||||
{
|
||||
var intToBoolConverter = new IntToBoolConverter();
|
||||
|
||||
var result = intToBoolConverter.ConvertBack(value, typeof(IntToBoolConverter_Tests), null, CultureInfo.CurrentCulture);
|
||||
var result = intToBoolConverter.ConvertBack(value, typeof(IntToBoolConverter_Tests), null, CultureInfo.CurrentCulture);
|
||||
|
||||
Assert.Equal(result, expectedResult);
|
||||
}
|
||||
Assert.Equal(result, expectedResult);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(2.5)]
|
||||
[InlineData("")]
|
||||
[InlineData(null)]
|
||||
public void InValidConverterValuesThrowArgumenException(object value)
|
||||
{
|
||||
var intToBoolConverter = new IntToBoolConverter();
|
||||
Assert.Throws<ArgumentException>(() => intToBoolConverter.Convert(value, typeof(IndexToArrayItemConverter), null, CultureInfo.CurrentCulture));
|
||||
}
|
||||
[Theory]
|
||||
[InlineData(2.5)]
|
||||
[InlineData("")]
|
||||
[InlineData(null)]
|
||||
public void InValidConverterValuesThrowArgumenException(object value)
|
||||
{
|
||||
var intToBoolConverter = new IntToBoolConverter();
|
||||
Assert.Throws<ArgumentException>(() => intToBoolConverter.Convert(value, typeof(IndexToArrayItemConverter), null, CultureInfo.CurrentCulture));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(2.5)]
|
||||
[InlineData("")]
|
||||
[InlineData(null)]
|
||||
public void InValidConverterBackValuesThrowArgumenException(object value)
|
||||
{
|
||||
var intToBoolConverter = new IntToBoolConverter();
|
||||
Assert.Throws<ArgumentException>(() => intToBoolConverter.ConvertBack(value, typeof(IndexToArrayItemConverter), null, CultureInfo.CurrentCulture));
|
||||
}
|
||||
}
|
||||
[Theory]
|
||||
[InlineData(2.5)]
|
||||
[InlineData("")]
|
||||
[InlineData(null)]
|
||||
public void InValidConverterBackValuesThrowArgumenException(object value)
|
||||
{
|
||||
var intToBoolConverter = new IntToBoolConverter();
|
||||
Assert.Throws<ArgumentException>(() => intToBoolConverter.ConvertBack(value, typeof(IndexToArrayItemConverter), null, CultureInfo.CurrentCulture));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,32 +1,32 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Xamarin.CommunityToolkit.Converters;
|
||||
using Xunit;
|
||||
|
||||
namespace Xamarin.CommunityToolkit.UnitTests.Converters
|
||||
{
|
||||
public class InvertedBoolConverter_Tests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(true, false)]
|
||||
[InlineData(false, true)]
|
||||
public void InverterBoolConverter(bool value, bool expectedResult)
|
||||
{
|
||||
var inverterBoolConverter = new InvertedBoolConverter();
|
||||
public class InvertedBoolConverter_Tests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(true, false)]
|
||||
[InlineData(false, true)]
|
||||
public void InverterBoolConverter(bool value, bool expectedResult)
|
||||
{
|
||||
var inverterBoolConverter = new InvertedBoolConverter();
|
||||
|
||||
var result = inverterBoolConverter.Convert(value, typeof(InvertedBoolConverter_Tests), null, CultureInfo.CurrentCulture);
|
||||
var result = inverterBoolConverter.Convert(value, typeof(InvertedBoolConverter_Tests), null, CultureInfo.CurrentCulture);
|
||||
|
||||
Assert.Equal(result, expectedResult);
|
||||
}
|
||||
Assert.Equal(result, expectedResult);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(2)]
|
||||
[InlineData("")]
|
||||
[InlineData(null)]
|
||||
public void InValidConverterValuesThrowArgumenException(object value)
|
||||
{
|
||||
var inverterBoolConverter = new InvertedBoolConverter();
|
||||
Assert.Throws<ArgumentException>(() => inverterBoolConverter.Convert(value, typeof(IndexToArrayItemConverter), null, CultureInfo.CurrentCulture));
|
||||
}
|
||||
}
|
||||
[Theory]
|
||||
[InlineData(2)]
|
||||
[InlineData("")]
|
||||
[InlineData(null)]
|
||||
public void InValidConverterValuesThrowArgumenException(object value)
|
||||
{
|
||||
var inverterBoolConverter = new InvertedBoolConverter();
|
||||
Assert.Throws<ArgumentException>(() => inverterBoolConverter.Convert(value, typeof(IndexToArrayItemConverter), null, CultureInfo.CurrentCulture));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,23 +1,23 @@
|
|||
using System.Globalization;
|
||||
using System.Globalization;
|
||||
using Xamarin.CommunityToolkit.Converters;
|
||||
using Xunit;
|
||||
|
||||
namespace Xamarin.CommunityToolkit.UnitTests.Converters
|
||||
{
|
||||
public class IsNotNullOrEmptyConverter_Tests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("Test", true)]
|
||||
[InlineData(typeof(IsNotNullOrEmptyConverter), true)]
|
||||
[InlineData(null, false)]
|
||||
[InlineData("", false)]
|
||||
public void IsNotNullOrEmptyConverter(object value, bool expectedResult)
|
||||
{
|
||||
var isNotNullOrEmptyConverter = new IsNotNullOrEmptyConverter();
|
||||
public class IsNotNullOrEmptyConverter_Tests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("Test", true)]
|
||||
[InlineData(typeof(IsNotNullOrEmptyConverter), true)]
|
||||
[InlineData(null, false)]
|
||||
[InlineData("", false)]
|
||||
public void IsNotNullOrEmptyConverter(object value, bool expectedResult)
|
||||
{
|
||||
var isNotNullOrEmptyConverter = new IsNotNullOrEmptyConverter();
|
||||
|
||||
var result = isNotNullOrEmptyConverter.Convert(value, typeof(IsNotNullOrEmptyConverter_Tests), null, CultureInfo.CurrentCulture);
|
||||
var result = isNotNullOrEmptyConverter.Convert(value, typeof(IsNotNullOrEmptyConverter_Tests), null, CultureInfo.CurrentCulture);
|
||||
|
||||
Assert.Equal(result, expectedResult);
|
||||
}
|
||||
}
|
||||
Assert.Equal(result, expectedResult);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,10 +11,10 @@ namespace Xamarin.CommunityToolkit.UnitTests.Converters
|
|||
{
|
||||
public static IEnumerable<object?[]> GetData() => new List<object?[]>
|
||||
{
|
||||
new object[] { new List<string>(), false},
|
||||
new object[] { new List<string>() { "TestValue"}, true},
|
||||
new object?[] { null, false},
|
||||
new object[] { Enumerable.Range(1, 3), true},
|
||||
new object[] { new List<string>(), false },
|
||||
new object[] { new List<string>() { "TestValue" }, true },
|
||||
new object?[] { null, false },
|
||||
new object[] { Enumerable.Range(1, 3), true },
|
||||
};
|
||||
|
||||
[Theory]
|
||||
|
|
|
@ -10,12 +10,12 @@ namespace Xamarin.CommunityToolkit.UnitTests.Converters
|
|||
public class ListIsNullOrEmptyConverter_Tests
|
||||
{
|
||||
public static IEnumerable<object?[]> GetData() => new List<object?[]>
|
||||
{
|
||||
new object[] { new List<string>(), true},
|
||||
new object[] { new List<string>() { "TestValue" }, false},
|
||||
new object?[] { null, true },
|
||||
new object[] { Enumerable.Range(1, 3), false },
|
||||
};
|
||||
{
|
||||
new object[] { new List<string>(), true },
|
||||
new object[] { new List<string>() { "TestValue" }, false },
|
||||
new object?[] { null, true },
|
||||
new object[] { Enumerable.Range(1, 3), false },
|
||||
};
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(GetData))]
|
||||
|
|
|
@ -1,29 +1,26 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Xamarin.CommunityToolkit.Converters;
|
||||
using Xunit;
|
||||
|
||||
namespace Xamarin.CommunityToolkit.UnitTests.Converters
|
||||
{
|
||||
public class MultiConverter_Tests
|
||||
{
|
||||
public static IEnumerable<object[]> GetData()
|
||||
{
|
||||
return new List<object[]>
|
||||
{
|
||||
new object[] { new List<MultiConverterParameter>() { { new MultiConverterParameter() { Value = "Param 1", } } , { new MultiConverterParameter() { Value = "Param 2", } } }},
|
||||
};
|
||||
}
|
||||
public class MultiConverter_Tests
|
||||
{
|
||||
public static IEnumerable<object[]> GetData() => new List<object[]>
|
||||
{
|
||||
new object[] { new List<MultiConverterParameter>() { { new MultiConverterParameter() { Value = "Param 1", } }, { new MultiConverterParameter() { Value = "Param 2", } } } },
|
||||
};
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(GetData))]
|
||||
public void MultiConverter(object value)
|
||||
{
|
||||
var multiConverter = new MultiConverter();
|
||||
[Theory]
|
||||
[MemberData(nameof(GetData))]
|
||||
public void MultiConverter(object value)
|
||||
{
|
||||
var multiConverter = new MultiConverter();
|
||||
|
||||
var result = multiConverter.Convert(value, typeof(MultiConverter), null, CultureInfo.CurrentCulture);
|
||||
var result = multiConverter.Convert(value, typeof(MultiConverter), null, CultureInfo.CurrentCulture);
|
||||
|
||||
Assert.Equal(result, value);
|
||||
}
|
||||
}
|
||||
Assert.Equal(result, value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,23 +1,23 @@
|
|||
using System.Globalization;
|
||||
using System.Globalization;
|
||||
using Xamarin.CommunityToolkit.Converters;
|
||||
using Xunit;
|
||||
|
||||
namespace Xamarin.CommunityToolkit.UnitTests.Converters
|
||||
{
|
||||
public class NotEqualConverter_Tests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(true, true, false)]
|
||||
[InlineData(int.MaxValue, int.MinValue, true)]
|
||||
[InlineData("Test", true, true)]
|
||||
[InlineData(null, null, false)]
|
||||
public void NotEqualConverter(object value, object comparedValue, bool expectedResult)
|
||||
{
|
||||
var notEqualConverter = new NotEqualConverter();
|
||||
public class NotEqualConverter_Tests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(true, true, false)]
|
||||
[InlineData(int.MaxValue, int.MinValue, true)]
|
||||
[InlineData("Test", true, true)]
|
||||
[InlineData(null, null, false)]
|
||||
public void NotEqualConverter(object value, object comparedValue, bool expectedResult)
|
||||
{
|
||||
var notEqualConverter = new NotEqualConverter();
|
||||
|
||||
var result = notEqualConverter.Convert(value, typeof(NotEqualConverter_Tests), comparedValue, CultureInfo.CurrentCulture);
|
||||
var result = notEqualConverter.Convert(value, typeof(NotEqualConverter_Tests), comparedValue, CultureInfo.CurrentCulture);
|
||||
|
||||
Assert.Equal(result, expectedResult);
|
||||
}
|
||||
}
|
||||
Assert.Equal(result, expectedResult);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,44 +1,44 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Xamarin.CommunityToolkit.Converters;
|
||||
using Xunit;
|
||||
|
||||
namespace Xamarin.CommunityToolkit.UnitTests.Converters
|
||||
{
|
||||
public class TextCaseConverter_Tests
|
||||
{
|
||||
const string test = nameof(test);
|
||||
const string t = nameof(t);
|
||||
public class TextCaseConverter_Tests
|
||||
{
|
||||
const string test = nameof(test);
|
||||
const string t = nameof(t);
|
||||
|
||||
[Theory]
|
||||
[InlineData(test, TextCaseType.Lower, test)]
|
||||
[InlineData(test, TextCaseType.Upper, "TEST")]
|
||||
[InlineData(test, TextCaseType.None, test)]
|
||||
[InlineData(test, TextCaseType.FirstUpperRestLower, "Test")]
|
||||
[InlineData(t, TextCaseType.Upper, "T")]
|
||||
[InlineData(t, TextCaseType.Lower, t)]
|
||||
[InlineData(t, TextCaseType.None, t)]
|
||||
[InlineData(t, TextCaseType.FirstUpperRestLower, "T")]
|
||||
[InlineData("", TextCaseType.FirstUpperRestLower, "")]
|
||||
[InlineData(null, null, null)]
|
||||
public void TextCaseConverter(object value, object comparedValue, object expectedResult)
|
||||
{
|
||||
var textCaseConverter = new TextCaseConverter();
|
||||
[Theory]
|
||||
[InlineData(test, TextCaseType.Lower, test)]
|
||||
[InlineData(test, TextCaseType.Upper, "TEST")]
|
||||
[InlineData(test, TextCaseType.None, test)]
|
||||
[InlineData(test, TextCaseType.FirstUpperRestLower, "Test")]
|
||||
[InlineData(t, TextCaseType.Upper, "T")]
|
||||
[InlineData(t, TextCaseType.Lower, t)]
|
||||
[InlineData(t, TextCaseType.None, t)]
|
||||
[InlineData(t, TextCaseType.FirstUpperRestLower, "T")]
|
||||
[InlineData("", TextCaseType.FirstUpperRestLower, "")]
|
||||
[InlineData(null, null, null)]
|
||||
public void TextCaseConverter(object value, object comparedValue, object expectedResult)
|
||||
{
|
||||
var textCaseConverter = new TextCaseConverter();
|
||||
|
||||
var result = textCaseConverter.Convert(value, typeof(TextCaseConverter_Tests), comparedValue, CultureInfo.CurrentCulture);
|
||||
var result = textCaseConverter.Convert(value, typeof(TextCaseConverter_Tests), comparedValue, CultureInfo.CurrentCulture);
|
||||
|
||||
Assert.Equal(result, expectedResult);
|
||||
}
|
||||
Assert.Equal(result, expectedResult);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0)]
|
||||
[InlineData(int.MinValue)]
|
||||
[InlineData(double.MaxValue)]
|
||||
public void InValidConverterValuesThrowArgumenException(object value)
|
||||
{
|
||||
var textCaseConverter = new TextCaseConverter();
|
||||
[Theory]
|
||||
[InlineData(0)]
|
||||
[InlineData(int.MinValue)]
|
||||
[InlineData(double.MaxValue)]
|
||||
public void InValidConverterValuesThrowArgumenException(object value)
|
||||
{
|
||||
var textCaseConverter = new TextCaseConverter();
|
||||
|
||||
Assert.Throws<ArgumentException>(() => textCaseConverter.Convert(value, typeof(TextCaseConverter_Tests), null, CultureInfo.CurrentCulture));
|
||||
}
|
||||
}
|
||||
Assert.Throws<ArgumentException>(() => textCaseConverter.Convert(value, typeof(TextCaseConverter_Tests), null, CultureInfo.CurrentCulture));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
|
@ -8,209 +8,209 @@ using Xunit.Sdk;
|
|||
|
||||
namespace Xamarin.CommunityToolkit.UnitTests.ObjectModel
|
||||
{
|
||||
public class ObservableRangeCollection_Tests
|
||||
{
|
||||
[Fact]
|
||||
public void AddRange()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>();
|
||||
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
|
||||
public class ObservableRangeCollection_Tests
|
||||
{
|
||||
[Fact]
|
||||
public void AddRange()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>();
|
||||
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
|
||||
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
Assert.Equal(NotifyCollectionChangedAction.Add, e.Action);
|
||||
Assert.Null(e.OldItems);
|
||||
Assert.Equal(toAdd, e.NewItems);
|
||||
};
|
||||
collection.AddRange(toAdd);
|
||||
}
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
Assert.Equal(NotifyCollectionChangedAction.Add, e.Action);
|
||||
Assert.Null(e.OldItems);
|
||||
Assert.Equal(toAdd, e.NewItems);
|
||||
};
|
||||
collection.AddRange(toAdd);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddRangeEmpty()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>();
|
||||
var toAdd = new int[0];
|
||||
[Fact]
|
||||
public void AddRangeEmpty()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>();
|
||||
var toAdd = new int[0];
|
||||
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
throw new XunitException("The event is raised.");
|
||||
};
|
||||
collection.AddRange(toAdd);
|
||||
}
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
throw new XunitException("The event is raised.");
|
||||
};
|
||||
collection.AddRange(toAdd);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReplaceRange()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>();
|
||||
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
|
||||
var toRemove = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0 };
|
||||
collection.AddRange(toRemove);
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
Assert.Equal(NotifyCollectionChangedAction.Reset, e.Action);
|
||||
[Fact]
|
||||
public void ReplaceRange()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>();
|
||||
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
|
||||
var toRemove = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0 };
|
||||
collection.AddRange(toRemove);
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
Assert.Equal(NotifyCollectionChangedAction.Reset, e.Action);
|
||||
|
||||
Assert.Null(e.OldItems);
|
||||
Assert.Null(e.NewItems);
|
||||
Assert.Null(e.OldItems);
|
||||
Assert.Null(e.NewItems);
|
||||
|
||||
Assert.Equal(collection.Count, toAdd.Length);
|
||||
Assert.Equal(collection.Count, toAdd.Length);
|
||||
|
||||
for (var i = 0; i < toAdd.Length; i++)
|
||||
{
|
||||
if (collection[i] != (int)toAdd[i])
|
||||
throw new XunitException("Expected and actual items don't match.");
|
||||
}
|
||||
};
|
||||
collection.ReplaceRange(toAdd);
|
||||
}
|
||||
for (var i = 0; i < toAdd.Length; i++)
|
||||
{
|
||||
if (collection[i] != (int)toAdd[i])
|
||||
throw new XunitException("Expected and actual items don't match.");
|
||||
}
|
||||
};
|
||||
collection.ReplaceRange(toAdd);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReplaceRange_on_non_empty_collection_should_always_raise_collection_changes()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>(new[] { 1 });
|
||||
var toAdd = new int[0];
|
||||
var eventRaised = false;
|
||||
[Fact]
|
||||
public void ReplaceRange_on_non_empty_collection_should_always_raise_collection_changes()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>(new[] { 1 });
|
||||
var toAdd = new int[0];
|
||||
var eventRaised = false;
|
||||
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
eventRaised = true;
|
||||
};
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
eventRaised = true;
|
||||
};
|
||||
|
||||
collection.ReplaceRange(toAdd);
|
||||
Assert.True(eventRaised, "Collection Reset should be raised.");
|
||||
}
|
||||
collection.ReplaceRange(toAdd);
|
||||
Assert.True(eventRaised, "Collection Reset should be raised.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReplaceRange_on_empty_collection_should_NOT_raise_collection_changes_when_empty()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>();
|
||||
var toAdd = new int[0];
|
||||
[Fact]
|
||||
public void ReplaceRange_on_empty_collection_should_NOT_raise_collection_changes_when_empty()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>();
|
||||
var toAdd = new int[0];
|
||||
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
throw new XunitException("Collection changes should NOT be raised.");
|
||||
};
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
throw new XunitException("Collection changes should NOT be raised.");
|
||||
};
|
||||
|
||||
collection.ReplaceRange(toAdd);
|
||||
}
|
||||
collection.ReplaceRange(toAdd);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReplaceRange_should_NOT_mutate_source()
|
||||
{
|
||||
var sourceData = new List<int>(new[] { 1, 2, 3 });
|
||||
var collection = new ObservableRangeCollection<int>(new[] { 1, 2, 3, 4, 5, 6 });
|
||||
[Fact]
|
||||
public void ReplaceRange_should_NOT_mutate_source()
|
||||
{
|
||||
var sourceData = new List<int>(new[] { 1, 2, 3 });
|
||||
var collection = new ObservableRangeCollection<int>(new[] { 1, 2, 3, 4, 5, 6 });
|
||||
|
||||
collection.ReplaceRange(sourceData);
|
||||
collection.ReplaceRange(sourceData);
|
||||
|
||||
Assert.Equal(3, sourceData.Count);
|
||||
}
|
||||
Assert.Equal(3, sourceData.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveRangeRemoveFact()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>();
|
||||
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
|
||||
var toRemove = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0 };
|
||||
collection.AddRange(toAdd);
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
if (e.Action != NotifyCollectionChangedAction.Remove)
|
||||
throw new XunitException("RemoveRange didn't use Remove like requested.");
|
||||
if (e.OldItems == null)
|
||||
throw new XunitException("OldItems should not be null.");
|
||||
var expected = new int[] { 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 9, 9 };
|
||||
if (expected.Length != e.OldItems.Count)
|
||||
throw new XunitException("Expected and actual OldItems don't match.");
|
||||
for (var i = 0; i < expected.Length; i++)
|
||||
{
|
||||
if (expected[i] != (int?)e.OldItems[i])
|
||||
throw new XunitException("Expected and actual OldItems don't match.");
|
||||
}
|
||||
};
|
||||
collection.RemoveRange(toRemove, NotifyCollectionChangedAction.Remove);
|
||||
}
|
||||
[Fact]
|
||||
public void RemoveRangeRemoveFact()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>();
|
||||
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
|
||||
var toRemove = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0 };
|
||||
collection.AddRange(toAdd);
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
if (e.Action != NotifyCollectionChangedAction.Remove)
|
||||
throw new XunitException("RemoveRange didn't use Remove like requested.");
|
||||
if (e.OldItems == null)
|
||||
throw new XunitException("OldItems should not be null.");
|
||||
var expected = new int[] { 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 9, 9 };
|
||||
if (expected.Length != e.OldItems.Count)
|
||||
throw new XunitException("Expected and actual OldItems don't match.");
|
||||
for (var i = 0; i < expected.Length; i++)
|
||||
{
|
||||
if (expected[i] != (int?)e.OldItems[i])
|
||||
throw new XunitException("Expected and actual OldItems don't match.");
|
||||
}
|
||||
};
|
||||
collection.RemoveRange(toRemove, NotifyCollectionChangedAction.Remove);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveRangeEmpty()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>();
|
||||
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
|
||||
var toRemove = new int[0];
|
||||
collection.AddRange(toAdd);
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
throw new XunitException("The event is raised.");
|
||||
};
|
||||
collection.RemoveRange(toRemove, NotifyCollectionChangedAction.Remove);
|
||||
}
|
||||
[Fact]
|
||||
public void RemoveRangeEmpty()
|
||||
{
|
||||
var collection = new ObservableRangeCollection<int>();
|
||||
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
|
||||
var toRemove = new int[0];
|
||||
collection.AddRange(toAdd);
|
||||
collection.CollectionChanged += (s, e) =>
|
||||
{
|
||||
throw new XunitException("The event is raised.");
|
||||
};
|
||||
collection.RemoveRange(toRemove, NotifyCollectionChangedAction.Remove);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveRange_should_NOT_mutate_source_when_source_data_is_not_present()
|
||||
{
|
||||
var sourceData = new List<int>(new[] { 1, 2, 3 });
|
||||
var collection = new ObservableRangeCollection<int>(new[] { 4, 5, 6 });
|
||||
[Fact]
|
||||
public void RemoveRange_should_NOT_mutate_source_when_source_data_is_not_present()
|
||||
{
|
||||
var sourceData = new List<int>(new[] { 1, 2, 3 });
|
||||
var collection = new ObservableRangeCollection<int>(new[] { 4, 5, 6 });
|
||||
|
||||
collection.RemoveRange(sourceData, NotifyCollectionChangedAction.Remove);
|
||||
collection.RemoveRange(sourceData, NotifyCollectionChangedAction.Remove);
|
||||
|
||||
Assert.Equal(3, sourceData.Count);
|
||||
}
|
||||
Assert.Equal(3, sourceData.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveRange_should_NOT_mutate_source_when_source_data_is_present()
|
||||
{
|
||||
var sourceData = new List<int>(new[] { 1, 2, 3 });
|
||||
var collection = new ObservableRangeCollection<int>(new[] { 1, 2, 3, 4, 5, 6 });
|
||||
[Fact]
|
||||
public void RemoveRange_should_NOT_mutate_source_when_source_data_is_present()
|
||||
{
|
||||
var sourceData = new List<int>(new[] { 1, 2, 3 });
|
||||
var collection = new ObservableRangeCollection<int>(new[] { 1, 2, 3, 4, 5, 6 });
|
||||
|
||||
collection.RemoveRange(sourceData, NotifyCollectionChangedAction.Remove);
|
||||
collection.RemoveRange(sourceData, NotifyCollectionChangedAction.Remove);
|
||||
|
||||
Assert.Equal(3, sourceData.Count);
|
||||
}
|
||||
Assert.Equal(3, sourceData.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RemoveRange_should_NOT_mutate_collection_when_source_data_is_not_present()
|
||||
{
|
||||
var sourceData = new List<int>(new[] { 1, 2, 3 });
|
||||
var collection = new ObservableRangeCollection<int>(new[] { 4, 5, 6, 7, 8, 9 });
|
||||
[Fact]
|
||||
public void RemoveRange_should_NOT_mutate_collection_when_source_data_is_not_present()
|
||||
{
|
||||
var sourceData = new List<int>(new[] { 1, 2, 3 });
|
||||
var collection = new ObservableRangeCollection<int>(new[] { 4, 5, 6, 7, 8, 9 });
|
||||
|
||||
collection.RemoveRange(sourceData, NotifyCollectionChangedAction.Remove);
|
||||
collection.RemoveRange(sourceData, NotifyCollectionChangedAction.Remove);
|
||||
|
||||
// the collection should not be modified if the source items are not found
|
||||
Assert.Equal(6, collection.Count);
|
||||
}
|
||||
// the collection should not be modified if the source items are not found
|
||||
Assert.Equal(6, collection.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddCollection()
|
||||
{
|
||||
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
|
||||
[Fact]
|
||||
public void AddCollection()
|
||||
{
|
||||
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
|
||||
|
||||
var wrapper = new CollectionWrapper<int>()
|
||||
{
|
||||
Collection = { toAdd }
|
||||
};
|
||||
var wrapper = new CollectionWrapper<int>()
|
||||
{
|
||||
Collection = { toAdd }
|
||||
};
|
||||
|
||||
Assert.Equal(toAdd, wrapper.Collection);
|
||||
}
|
||||
Assert.Equal(toAdd, wrapper.Collection);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddToNullCollection()
|
||||
{
|
||||
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
|
||||
[Fact]
|
||||
public void AddToNullCollection()
|
||||
{
|
||||
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
|
||||
|
||||
#pragma warning disable CS8670 // Object or collection initializer implicitly dereferences possibly null member.
|
||||
Assert.Throws<ArgumentNullException>(() =>
|
||||
{
|
||||
var wrapper = new CollectionWrapper<int>()
|
||||
{
|
||||
NullCollection = { toAdd }
|
||||
};
|
||||
});
|
||||
Assert.Throws<ArgumentNullException>(() =>
|
||||
{
|
||||
var wrapper = new CollectionWrapper<int>()
|
||||
{
|
||||
NullCollection = { toAdd }
|
||||
};
|
||||
});
|
||||
#pragma warning restore CS8670 // Object or collection initializer implicitly dereferences possibly null member.
|
||||
}
|
||||
}
|
||||
|
||||
class CollectionWrapper<T>
|
||||
{
|
||||
public ObservableRangeCollection<T> Collection { get; } = new ObservableRangeCollection<T>();
|
||||
class CollectionWrapper<T>
|
||||
{
|
||||
public ObservableRangeCollection<T> Collection { get; } = new ObservableRangeCollection<T>();
|
||||
|
||||
public ObservableRangeCollection<T>? NullCollection { get; init; }
|
||||
}
|
||||
}
|
||||
public ObservableRangeCollection<T>? NullCollection { get; init; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
@ -8,58 +8,58 @@ using Xamarin.Forms;
|
|||
|
||||
namespace Xamarin.CommunityToolkit.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert an <see cref="Enum" /> to corresponding <see cref="bool" />
|
||||
/// </summary>
|
||||
public class EnumToBoolConverter : ValueConverterExtension, IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum values, that converts to <c>true</c> (optional)
|
||||
/// </summary>
|
||||
public IList<Enum> TrueValues { get; } = new List<Enum>();
|
||||
/// <summary>
|
||||
/// Convert an <see cref="Enum" /> to corresponding <see cref="bool" />
|
||||
/// </summary>
|
||||
public class EnumToBoolConverter : ValueConverterExtension, IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum values, that converts to <c>true</c> (optional)
|
||||
/// </summary>
|
||||
public IList<Enum> TrueValues { get; } = new List<Enum>();
|
||||
|
||||
/// <summary>
|
||||
/// Convert an <see cref="Enum" /> to corresponding <see cref="bool" />
|
||||
/// </summary>
|
||||
/// <param name="value"><see cref="Enum" /> value to convert</param>
|
||||
/// <param name="targetType">The type of the binding target property. This is not implemented.</param>
|
||||
/// <param name="parameter">
|
||||
/// Additional parameter for converter. Can be used for comparison instead of
|
||||
/// <see cref="TrueValues" />
|
||||
/// </param>
|
||||
/// <param name="culture">The culture to use in the converter. This is not implemented.</param>
|
||||
/// <returns>
|
||||
/// False, if the value is not in <see cref="TrueValues" />. False, if <see cref="TrueValues" /> is empty and
|
||||
/// value not equal to parameter.
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentException">If value is not an <see cref="Enum" /></exception>
|
||||
public object Convert(object ?value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is not Enum enumValue)
|
||||
throw new ArgumentException("The value should be of type Enum", nameof(value));
|
||||
/// <summary>
|
||||
/// Convert an <see cref="Enum" /> to corresponding <see cref="bool" />
|
||||
/// </summary>
|
||||
/// <param name="value"><see cref="Enum" /> value to convert</param>
|
||||
/// <param name="targetType">The type of the binding target property. This is not implemented.</param>
|
||||
/// <param name="parameter">
|
||||
/// Additional parameter for converter. Can be used for comparison instead of
|
||||
/// <see cref="TrueValues" />
|
||||
/// </param>
|
||||
/// <param name="culture">The culture to use in the converter. This is not implemented.</param>
|
||||
/// <returns>
|
||||
/// False, if the value is not in <see cref="TrueValues" />. False, if <see cref="TrueValues" /> is empty and
|
||||
/// value not equal to parameter.
|
||||
/// </returns>
|
||||
/// <exception cref="ArgumentException">If value is not an <see cref="Enum" /></exception>
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is not Enum enumValue)
|
||||
throw new ArgumentException("The value should be of type Enum", nameof(value));
|
||||
|
||||
return TrueValues.Count == 0
|
||||
? CompareTwoEnums(enumValue, parameter as Enum)
|
||||
: TrueValues.Any(item => CompareTwoEnums(enumValue, item));
|
||||
return TrueValues.Count == 0
|
||||
? CompareTwoEnums(enumValue, parameter as Enum)
|
||||
: TrueValues.Any(item => CompareTwoEnums(enumValue, item));
|
||||
|
||||
static bool CompareTwoEnums(Enum valueToCheck, object? referenceValue)
|
||||
{
|
||||
if (referenceValue is not Enum referenceEnumValue)
|
||||
return false;
|
||||
static bool CompareTwoEnums(Enum valueToCheck, object? referenceValue)
|
||||
{
|
||||
if (referenceValue is not Enum referenceEnumValue)
|
||||
return false;
|
||||
|
||||
var valueToCheckType = valueToCheck.GetType();
|
||||
if (valueToCheckType != referenceEnumValue.GetType())
|
||||
return false;
|
||||
var valueToCheckType = valueToCheck.GetType();
|
||||
if (valueToCheckType != referenceEnumValue.GetType())
|
||||
return false;
|
||||
|
||||
if (valueToCheckType.GetTypeInfo().GetCustomAttribute<FlagsAttribute>() != null)
|
||||
return referenceEnumValue.HasFlag(valueToCheck);
|
||||
if (valueToCheckType.GetTypeInfo().GetCustomAttribute<FlagsAttribute>() != null)
|
||||
return referenceEnumValue.HasFlag(valueToCheck);
|
||||
|
||||
return Equals(valueToCheck, referenceEnumValue);
|
||||
}
|
||||
}
|
||||
return Equals(valueToCheck, referenceEnumValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public object ConvertBack(object? value, Type? targetType, object? parameter, CultureInfo? culture) =>
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public object ConvertBack(object? value, Type? targetType, object? parameter, CultureInfo? culture) =>
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Xamarin.CommunityToolkit.Converters
|
|||
/// <param name="culture">The culture to use in the converter.</param>
|
||||
/// <returns>The converted value.</returns>
|
||||
public object? Convert(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture)
|
||||
=> parameter is IList<MultiConverterParameter> parameters
|
||||
=> parameter is IList<MultiConverterParameter> parameters
|
||||
? this.Aggregate(value, (current, converter) => converter.Convert(current, targetType,
|
||||
parameters.FirstOrDefault(x => x.ConverterType == converter.GetType())?.Value, culture))
|
||||
: this.Aggregate(value, (current, converter) => converter.Convert(current, targetType, parameter, culture));
|
||||
|
|
|
@ -41,13 +41,14 @@ namespace Xamarin.CommunityToolkit.Effects
|
|||
/// </summary>
|
||||
public static string TouchEffect => $"{effectResolutionGroupName}.{nameof(TouchEffect)}";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Effect Id for <see cref="LifeCycleEffect"/>
|
||||
/// </summary>
|
||||
public static string LifeCycleEffect => $"{effectResolutionGroupName}.{nameof(LifecycleEffect)}";
|
||||
|
||||
/// <summary>
|
||||
/// Effect Id for <see cref="ShadowEffect"/>
|
||||
/// </summary>
|
||||
public static string ShadowEffect => $"{effectResolutionGroupName}.{nameof(ShadowEffect)}";
|
||||
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ namespace Xamarin.CommunityToolkit.Effects
|
|||
public SelectAllTextEffect()
|
||||
: base(EffectIds.SelectAllText)
|
||||
{
|
||||
#region Required work-around to prevent linker from removing the platform-specific implementation
|
||||
#region Required work-around to prevent linker from removing the platform-specific implementation
|
||||
#if __IOS__
|
||||
if (DateTime.Now.Ticks < 0)
|
||||
_ = new Xamarin.CommunityToolkit.iOS.Effects.SelectAllTextEffect();
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Xamarin.CommunityToolkit.Android.Effects
|
|||
FrameLayout? rippleOverlay;
|
||||
FastRendererOnLayoutChangeListener? fastListener;
|
||||
|
||||
bool IsClickable => Element is not (Layout or BoxView);
|
||||
bool IsClickable => Element is not Layout or BoxView;
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
|
|
|
@ -112,7 +112,6 @@ namespace Xamarin.CommunityToolkit.UI.Views
|
|||
Color.FromRgb(168, 101, 30)
|
||||
});
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A Ocean inspirated <see cref="ColorTheme"/>.
|
||||
/// </summary>
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
|
|||
return false;
|
||||
|
||||
// Let the container know that we're "fake" handling this event
|
||||
//renderer.NotifyFakeHandling();
|
||||
// renderer.NotifyFakeHandling();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
|
|||
public class MediaCapturedEventArgs : EventArgs
|
||||
{
|
||||
readonly string? path;
|
||||
readonly Lazy<ImageSource> imageSource;
|
||||
readonly Lazy<ImageSource?> imageSource;
|
||||
readonly Lazy<XCT.FileMediaSource?> mediaSource;
|
||||
|
||||
internal MediaCapturedEventArgs(
|
||||
|
@ -20,7 +20,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
|
|||
this.path = path;
|
||||
Rotation = rotation;
|
||||
ImageData = imageData;
|
||||
imageSource = new Lazy<ImageSource>(GetImageSource);
|
||||
imageSource = new Lazy<ImageSource?>(GetImageSource);
|
||||
mediaSource = new Lazy<XCT.FileMediaSource?>(GetMediaSource);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
|
|||
|
||||
public XCT.FileMediaSource? Video => mediaSource.Value;
|
||||
|
||||
ImageSource GetImageSource()
|
||||
ImageSource? GetImageSource()
|
||||
{
|
||||
if (ImageData != null)
|
||||
return ImageSource.FromStream(() => new MemoryStream(ImageData));
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
using System;
|
||||
using System;
|
||||
|
||||
namespace Xamarin.CommunityToolkit.UI.Views.iOSSpecific
|
||||
{
|
||||
public enum PopoverArrowDirection
|
||||
{
|
||||
None,
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right,
|
||||
Any,
|
||||
Unknown
|
||||
}
|
||||
public enum PopoverArrowDirection
|
||||
{
|
||||
None,
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right,
|
||||
Any,
|
||||
Unknown
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Xamarin.CommunityToolkit.UI.Views.iOSSpecific
|
||||
{
|
||||
public static class Popup
|
||||
{
|
||||
public static readonly BindableProperty ArrowDirectionProperty = BindableProperty.Create(
|
||||
"ArrowDirection", typeof(PopoverArrowDirection), typeof(Views.Popup), PopoverArrowDirection.None);
|
||||
public static class Popup
|
||||
{
|
||||
public static readonly BindableProperty ArrowDirectionProperty = BindableProperty.Create(
|
||||
"ArrowDirection", typeof(PopoverArrowDirection), typeof(Views.Popup), PopoverArrowDirection.None);
|
||||
|
||||
public static void SetArrowDirection(BindableObject element, PopoverArrowDirection color) =>
|
||||
element.SetValue(ArrowDirectionProperty, color);
|
||||
public static void SetArrowDirection(BindableObject element, PopoverArrowDirection color) =>
|
||||
element.SetValue(ArrowDirectionProperty, color);
|
||||
|
||||
public static PopoverArrowDirection GetArrowDirection(BindableObject element) =>
|
||||
(PopoverArrowDirection)element.GetValue(ArrowDirectionProperty);
|
||||
}
|
||||
public static PopoverArrowDirection GetArrowDirection(BindableObject element) =>
|
||||
(PopoverArrowDirection)element.GetValue(ArrowDirectionProperty);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace Xamarin.CommunityToolkit.UI.Views
|
|||
if (view != null)
|
||||
return view;
|
||||
|
||||
return new Label{ Text = $"View for {state}{customState} not defined." };
|
||||
return new Label { Text = $"View for {state}{customState} not defined." };
|
||||
}
|
||||
|
||||
async Task ChildrenFadeTo(Layout<View> layout, bool animate, bool isHide)
|
||||
|
|
Загрузка…
Ссылка в новой задаче