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-06-07 21:49:35 +0300
committerEric Maupin <ermaup@microsoft.com>2018-06-12 19:59:26 +0300
commitb89196812cea3c26eecac4a0c90115e9501f3bfa (patch)
treea4fc868922c5d0b4b87663bdf700c4280115086e /Xamarin.PropertyEditing.Tests/MaterialDesignColorViewModelTests.cs
parent3e1160f9979508063c4ba451173454152615c179 (diff)
[Core] Don't switch to material if brush matches but is a resource
Diffstat (limited to 'Xamarin.PropertyEditing.Tests/MaterialDesignColorViewModelTests.cs')
-rw-r--r--Xamarin.PropertyEditing.Tests/MaterialDesignColorViewModelTests.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/Xamarin.PropertyEditing.Tests/MaterialDesignColorViewModelTests.cs b/Xamarin.PropertyEditing.Tests/MaterialDesignColorViewModelTests.cs
index b816965..d211599 100644
--- a/Xamarin.PropertyEditing.Tests/MaterialDesignColorViewModelTests.cs
+++ b/Xamarin.PropertyEditing.Tests/MaterialDesignColorViewModelTests.cs
@@ -1,5 +1,7 @@
using System;
using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
using Moq;
using NUnit.Framework;
using Xamarin.PropertyEditing.Drawing;
@@ -240,6 +242,33 @@ namespace Xamarin.PropertyEditing.Tests
Assert.That (vm.Solid.Color, Is.EqualTo (darkNormalColor));
}
+ [Test]
+ [Description ("If we have a resource brush value that matches material, we need to ensure it doesn't auto switch to material")]
+ public async Task ResourceBrushMatchesMaterialStaysResource()
+ {
+ var platform = new TargetPlatform (new MockEditorProvider ()) {
+ SupportsMaterialDesign = true
+ };
+ var mockProperty = new Mock<IPropertyInfo> ();
+ mockProperty.SetupGet (pi => pi.Type).Returns (typeof (CommonSolidBrush));
+
+ var mockEditor = new MockObjectEditor (mockProperty.Object);
+
+ var provider = new MockResourceProvider ();
+ var resources = await provider.GetResourcesAsync (mockEditor.Target, mockProperty.Object, CancellationToken.None);
+ var resource = resources.OfType<Resource<CommonSolidBrush>> ().First (r => r.Value == new CommonSolidBrush (0, 0, 0));
+
+ await mockEditor.SetValueAsync (mockProperty.Object, new ValueInfo<CommonSolidBrush> {
+ Source = ValueSource.Resource,
+ Value = resource.Value,
+ ValueDescriptor = resource
+ });
+
+ var vm = new BrushPropertyViewModel (platform, mockProperty.Object, new[] { mockEditor });
+ Assume.That (vm.ValueSource, Is.EqualTo (ValueSource.Resource));
+ Assert.That (vm.SelectedBrushType, Is.EqualTo (CommonBrushType.Resource));
+ }
+
protected override CommonBrush GetRandomTestValue (Random rand)
{
CommonColor color = rand.NextColor ();