diff options
Diffstat (limited to 'Xamarin.PropertyEditing.Tests')
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; |