diff options
author | Eric Maupin <ermaup@microsoft.com> | 2018-08-14 22:57:12 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2018-08-17 19:37:28 +0300 |
commit | 64156ba108a6111cb129af16e57737186f85a8d5 (patch) | |
tree | 41e4a685948e54a9abfda4f111b068215312b1d0 | |
parent | 7568c752ba9f515894fc13a0a1b8a2e6039383e0 (diff) |
[Test] Fix resource based tests
-rw-r--r-- | Xamarin.PropertyEditing.Tests/PropertyViewModelTests.cs | 58 |
1 files changed, 1 insertions, 57 deletions
diff --git a/Xamarin.PropertyEditing.Tests/PropertyViewModelTests.cs b/Xamarin.PropertyEditing.Tests/PropertyViewModelTests.cs index f206158..00d7e3b 100644 --- a/Xamarin.PropertyEditing.Tests/PropertyViewModelTests.cs +++ b/Xamarin.PropertyEditing.Tests/PropertyViewModelTests.cs @@ -303,11 +303,7 @@ namespace Xamarin.PropertyEditing.Tests resourcesMock.Setup (rp => rp.GetResourcesAsync (editor.Target, mockProperty.Object, It.IsAny<CancellationToken> ())).ReturnsAsync (new[] { resource }); var vm = GetViewModel (new TargetPlatform (new MockEditorProvider (), resourcesMock.Object), mockProperty.Object, new[] { editor }); - Assume.That (vm.SetValueResourceCommand.CanExecute (resource), Is.False); - - bool changed = false; - vm.SetValueResourceCommand.CanExecuteChanged += (o,e) => changed = true; - Assume.That (changed, Is.True); + Assume.That (vm.SupportsResources, Is.True, "Does not support resources"); Assume.That (vm.SetValueResourceCommand, Is.Not.Null); Assert.That (vm.SetValueResourceCommand.CanExecute (resource), Is.True, "Could not set value to resource"); } @@ -344,32 +340,6 @@ namespace Xamarin.PropertyEditing.Tests Assert.That (vm.RequestResourceCommand.CanExecute (null), Is.True); } - - [Test] - public void CanSetValueResourceUpdatesOnProviderSet() - { - var mockProperty = GetPropertyMock (); - mockProperty.SetupGet (pi => pi.CanWrite).Returns (true); - mockProperty.SetupGet (pi => pi.ValueSources).Returns (ValueSources.Resource); - - var resource = new Resource ("name"); - - var editor = GetBasicEditor (mockProperty.Object); - - var resourcesMock = new Mock<IResourceProvider> (); - resourcesMock.Setup (rp => rp.GetResourcesAsync (editor.Target, mockProperty.Object, It.IsAny<CancellationToken> ())).ReturnsAsync (new[] { resource }); - - var vm = GetViewModel (new TargetPlatform (new MockEditorProvider (), resourcesMock.Object), mockProperty.Object, new[] { editor }); - Assume.That (vm.SetValueResourceCommand.CanExecute (resource), Is.False); - - bool setChanged = false; - vm.SetValueResourceCommand.CanExecuteChanged += (o,e) => setChanged = true; - - Assume.That (vm.SetValueResourceCommand.CanExecute (resource), Is.False); - - Assert.That (setChanged, Is.True); - Assert.That (vm.SetValueResourceCommand.CanExecute (resource), Is.True); - } [Test] public void CanRequestResourceNoProvider() @@ -387,32 +357,6 @@ namespace Xamarin.PropertyEditing.Tests var vm = GetViewModel (mockProperty.Object, new[] { editor }); Assert.That (vm.RequestResourceCommand.CanExecute (null), Is.False); } - - [Test] - [Description ("RequestResourceCommand's CanExecuteChanged should fire when SetValueResourceCommand's does")] - public void CanRequestResourceSetValueChanges() - { - var mockProperty = GetPropertyMock (); - mockProperty.SetupGet (pi => pi.CanWrite).Returns (true); - - var resource = new Resource ("name"); - - var editor = GetBasicEditor (mockProperty.Object); - var resourcesMock = new Mock<IResourceProvider> (); - resourcesMock.Setup (rp => rp.GetResourcesAsync (editor.Target, mockProperty.Object, It.IsAny<CancellationToken> ())).ReturnsAsync (new[] { resource }); - - var vm = GetViewModel (new TargetPlatform (new MockEditorProvider (), resourcesMock.Object), mockProperty.Object, new[] { editor }); - Assume.That (vm.SetValueResourceCommand.CanExecute (resource), Is.False); - Assume.That (vm.RequestResourceCommand.CanExecute (null), Is.False); - - bool setChanged = false; - vm.SetValueResourceCommand.CanExecuteChanged += (o,e) => setChanged = true; - bool requestChanged = false; - vm.RequestResourceCommand.CanExecuteChanged += (o, e) => requestChanged = true; - - Assume.That (setChanged, Is.True); - Assert.That (requestChanged, Is.True); - } [Test] public void SetValueToResource () |