Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Maupin <ermaup@microsoft.com>2018-08-17 23:29:51 +0300
committerEric Maupin <ermaup@microsoft.com>2018-10-17 22:12:52 +0300
commit41bb09e03bc5fc9cfdeb1a2d5bcf1008c7064190 (patch)
treede213554a0106499ddbac9345a1fc211841f643c /Xamarin.PropertyEditing.Tests
parent022c999f29aa6ba08eb1e0531f3d6a79daee9156 (diff)
[Tests] Add Variation property
Diffstat (limited to 'Xamarin.PropertyEditing.Tests')
-rw-r--r--Xamarin.PropertyEditing.Tests/MockControls/MockControl.cs8
-rw-r--r--Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs10
-rw-r--r--Xamarin.PropertyEditing.Tests/MockPropertyInfo/MockEnumPropertyInfo.cs4
-rw-r--r--Xamarin.PropertyEditing.Tests/MockPropertyInfo/MockPropertyInfo.cs11
4 files changed, 23 insertions, 10 deletions
diff --git a/Xamarin.PropertyEditing.Tests/MockControls/MockControl.cs b/Xamarin.PropertyEditing.Tests/MockControls/MockControl.cs
index d11daf9..6a96102 100644
--- a/Xamarin.PropertyEditing.Tests/MockControls/MockControl.cs
+++ b/Xamarin.PropertyEditing.Tests/MockControls/MockControl.cs
@@ -15,18 +15,18 @@ namespace Xamarin.PropertyEditing.Tests.MockControls
bool canWrite = true, bool flag = false,
IEnumerable<Type> converterTypes = null,
string description = null, bool constrained = true, ValueSources valueSources = ValueSources.Local | ValueSources.Default | ValueSources.Binding,
- IReadOnlyList<InputMode> inputModes = null)
+ IReadOnlyList<InputMode> inputModes = null, PropertyVariation[] variations = null)
{
IPropertyInfo propertyInfo;
if (typeof(T).IsEnum) {
var underlyingType = typeof (T).GetEnumUnderlyingType ();
var enumPropertyInfoType = typeof (MockEnumPropertyInfo<,>)
.MakeGenericType (underlyingType, typeof (T));
- propertyInfo = (IPropertyInfo)Activator.CreateInstance (enumPropertyInfoType, name, description, category, canWrite, flag, converterTypes, constrained);
+ propertyInfo = (IPropertyInfo)Activator.CreateInstance (enumPropertyInfoType, name, description, category, canWrite, flag, converterTypes, constrained, variations);
} else if (inputModes != null) {
- propertyInfo = new MockPropertyInfoWithInputTypes<T> (name, inputModes, description, category, canWrite, converterTypes, valueSources);
+ propertyInfo = new MockPropertyInfoWithInputTypes<T> (name, inputModes, description, category, canWrite, converterTypes, valueSources, variations);
} else {
- propertyInfo = new MockPropertyInfo<T> (name, description, category, canWrite, converterTypes, valueSources);
+ propertyInfo = new MockPropertyInfo<T> (name, description, category, canWrite, converterTypes, valueSources, variations);
}
AddProperty<T> (propertyInfo);
diff --git a/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs b/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs
index 75c69b6..49a1b22 100644
--- a/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs
+++ b/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs
@@ -18,6 +18,16 @@ namespace Xamarin.PropertyEditing.Tests.MockControls
AddProperty<string> ("String", ReadWrite, valueSources: ValueSources.Local | ValueSources.Resource | ValueSources.Binding);
AddProperty<int> ("Width", ReadWrite, valueSources: ValueSources.Local | ValueSources.Resource | ValueSources.Binding, inputModes: new[] { new InputMode("Auto", true), new InputMode("Star"), new InputMode("Pixel"), });
AddProperty<Enumeration> ("Enumeration", ReadWrite, constrained: false);
+ AddProperty<string> ("StringV", ReadWrite, valueSources: ValueSources.Local | ValueSources.Resource | ValueSources.Binding,
+ variations: new [] {
+ new PropertyVariation ("Width", "Compact"),
+ new PropertyVariation ("Width", "Regular"),
+ new PropertyVariation ("Gamut", "P3"),
+ new PropertyVariation ("Gamut", "sRGB"),
+ new PropertyVariation ("OnPlatform", "iOS"),
+ new PropertyVariation ("OnPlatform", "Android"),
+ new PropertyVariation ("OnPlatform", "UWP"),
+ });
AddProperty<FlagsNoValues> ("FlagsNoValues", ReadWrite, canWrite: true, flag: true);
AddProperty<FlagsWithValues> ("FlagsWithValues", ReadWrite, canWrite: true, flag: true);
AddProperty<CommonPoint> ("Point", ReadWrite);
diff --git a/Xamarin.PropertyEditing.Tests/MockPropertyInfo/MockEnumPropertyInfo.cs b/Xamarin.PropertyEditing.Tests/MockPropertyInfo/MockEnumPropertyInfo.cs
index fd4be86..983919f 100644
--- a/Xamarin.PropertyEditing.Tests/MockPropertyInfo/MockEnumPropertyInfo.cs
+++ b/Xamarin.PropertyEditing.Tests/MockPropertyInfo/MockEnumPropertyInfo.cs
@@ -15,8 +15,8 @@ namespace Xamarin.PropertyEditing.Tests.MockPropertyInfo
where TUnderlying : struct
where TEnum : struct
{
- public MockEnumPropertyInfo (string name, string description = null, string category = "", bool canWrite = true, bool flag = false, IEnumerable<Type> converterTypes = null, bool constrained = true)
- : base (name, description, category, canWrite, converterTypes)
+ public MockEnumPropertyInfo (string name, string description = null, string category = "", bool canWrite = true, bool flag = false, IEnumerable<Type> converterTypes = null, bool constrained = true, PropertyVariation[] variations = null)
+ : base (name, description, category, canWrite, converterTypes, variations: variations)
{
var names = Enum.GetNames (typeof (TEnum));
Values = Enum.GetValues (typeof (TEnum)).Cast<TUnderlying>().ToArray();
diff --git a/Xamarin.PropertyEditing.Tests/MockPropertyInfo/MockPropertyInfo.cs b/Xamarin.PropertyEditing.Tests/MockPropertyInfo/MockPropertyInfo.cs
index e21737e..e916f0e 100644
--- a/Xamarin.PropertyEditing.Tests/MockPropertyInfo/MockPropertyInfo.cs
+++ b/Xamarin.PropertyEditing.Tests/MockPropertyInfo/MockPropertyInfo.cs
@@ -9,8 +9,8 @@ namespace Xamarin.PropertyEditing.Tests.MockPropertyInfo
public class MockPropertyInfoWithInputTypes<T>
: MockPropertyInfo<T>, IHaveInputModes
{
- public MockPropertyInfoWithInputTypes (string name, IReadOnlyList<InputMode> inputModes, string description = null, string category = null, bool canWrite = true, IEnumerable<Type> converterTypes = null, ValueSources valueSources = ValueSources.Default | ValueSources.Local)
- : base (name, description, category, canWrite, converterTypes, valueSources)
+ public MockPropertyInfoWithInputTypes (string name, IReadOnlyList<InputMode> inputModes, string description = null, string category = null, bool canWrite = true, IEnumerable<Type> converterTypes = null, ValueSources valueSources = ValueSources.Default | ValueSources.Local, PropertyVariation[] variations = null)
+ : base (name, description, category, canWrite, converterTypes, valueSources, variations)
{
InputModes = inputModes.ToArray ();
}
@@ -23,7 +23,7 @@ namespace Xamarin.PropertyEditing.Tests.MockPropertyInfo
public class MockPropertyInfo<T> : IPropertyInfo, IPropertyConverter, IEquatable<MockPropertyInfo<T>>
{
- public MockPropertyInfo (string name, string description = null, string category = null, bool canWrite = true, IEnumerable<Type> converterTypes = null, ValueSources valueSources = ValueSources.Local | ValueSources.Default)
+ public MockPropertyInfo (string name, string description = null, string category = null, bool canWrite = true, IEnumerable<Type> converterTypes = null, ValueSources valueSources = ValueSources.Local | ValueSources.Default, PropertyVariation[] variations = null)
{
Name = name;
Description = description;
@@ -40,6 +40,8 @@ namespace Xamarin.PropertyEditing.Tests.MockPropertyInfo
if (typeof(T).IsValueType) {
this.nullConverter = new NullableConverter (typeof(Nullable<>).MakeGenericType (typeof(T)));
}
+
+ Variations = variations ?? EmptyVariations;
}
public string Name { get; }
@@ -52,7 +54,8 @@ namespace Xamarin.PropertyEditing.Tests.MockPropertyInfo
public bool CanWrite { get; }
public ValueSources ValueSources { get; }
static readonly PropertyVariation[] EmptyVariations = new PropertyVariation[0];
- public virtual IReadOnlyList<PropertyVariation> Variations => EmptyVariations;
+
+ public virtual IReadOnlyList<PropertyVariation> Variations { get; }
static readonly IAvailabilityConstraint[] EmptyConstraints = new IAvailabilityConstraint[0];
public virtual IReadOnlyList<IAvailabilityConstraint> AvailabilityConstraints => EmptyConstraints;