Use built-in Nunit method for waiting;

Avoid problems with Assert.Success throwing exception on wrong thread
This commit is contained in:
E.Z. Hart 2017-06-27 10:34:59 -06:00
Родитель 80ac8be42c
Коммит 318b50aa75
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 1196DD903A2F7606
1 изменённых файлов: 5 добавлений и 5 удалений

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

@ -605,7 +605,7 @@ namespace Xamarin.Forms.Core.UnitTests
}
[Test]
public async Task PropertyChangeBindingsOccurThroughMainThread()
public void PropertyChangeBindingsOccurThroughMainThread()
{
var vm = new MockViewModel { Text = "text" };
@ -614,13 +614,13 @@ namespace Xamarin.Forms.Core.UnitTests
bindable.BindingContext = vm;
bindable.SetBinding(MockBindable.TextProperty, binding);
Device.PlatformServices = new MockPlatformServices(a => Assert.Pass());
bool invokeOnMainThreadWasCalled = false;
Device.PlatformServices = new MockPlatformServices(a => invokeOnMainThreadWasCalled = true);
vm.Text = "updated";
// If we wait five seconds and Assert.Pass still hasn't been called, something is very wrong
await Task.Delay(5000);
Assert.Fail();
// If we wait five seconds and invokeOnMainThreadWasCalled still hasn't been set, something is very wrong
Assert.That(invokeOnMainThreadWasCalled, Is.True.After(5000, 10));
}
}