Fix (hopefully) for occasional failures in PropertyChangeBindingsOccurThroughMainThread test

This commit is contained in:
E.Z. Hart 2017-06-26 16:17:55 -06:00
Родитель 78546aed89
Коммит d308479def
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 1196DD903A2F7606
1 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using NUnit.Framework;
using Xamarin.Forms.Internals;
@ -604,7 +605,7 @@ namespace Xamarin.Forms.Core.UnitTests
}
[Test]
public void PropertyChangeBindingsOccurThroughMainThread()
public async Task PropertyChangeBindingsOccurThroughMainThread()
{
var vm = new MockViewModel { Text = "text" };
@ -613,13 +614,13 @@ namespace Xamarin.Forms.Core.UnitTests
bindable.BindingContext = vm;
bindable.SetBinding(MockBindable.TextProperty, binding);
bool mainThread = false;
Device.PlatformServices = new MockPlatformServices(invokeOnMainThread: a => mainThread = true);
Device.PlatformServices = new MockPlatformServices(a => Assert.Pass());
vm.Text = "updated";
Assert.IsTrue(mainThread, "Binding did not occur on main thread");
Assert.AreNotEqual(vm.Text, bindable.GetValue(MockBindable.TextProperty), "Binding was applied anyway through other means");
// If we wait five seconds and Assert.Pass still hasn't been called, something is very wrong
await Task.Delay(5000);
Assert.Fail();
}
}