mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-17 20:50:11 +00:00
Fixed edit mode, clear continuations and runners on run mode change, edit mode unit tests
This commit is contained in:
committed by
Antonio Ruggiero
parent
50ba93f951
commit
ecf6c1fba5
44
Assets/Tests/Editor/WhenAnyTestEditor.cs
Normal file
44
Assets/Tests/Editor/WhenAnyTestEditor.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Scripting;
|
||||
using UniRx;
|
||||
using UniRx.Async;
|
||||
using Unity.Collections;
|
||||
using System.Threading;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine.TestTools;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace UniRx.AsyncTests
|
||||
{
|
||||
public class WhenAnyTest
|
||||
{
|
||||
[UnityTest]
|
||||
public IEnumerator WhenAnyCanceled() => UniTask.ToCoroutine(async () =>
|
||||
{
|
||||
var cts = new CancellationTokenSource();
|
||||
var successDelayTask = UniTask.Delay(TimeSpan.FromSeconds(1));
|
||||
var cancelTask = UniTask.Delay(TimeSpan.FromSeconds(1), cancellationToken: cts.Token);
|
||||
cts.CancelAfterSlim(200);
|
||||
|
||||
try
|
||||
{
|
||||
var r = await UniTask.WhenAny(new[] { successDelayTask, cancelTask });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.Should().BeAssignableTo<OperationCanceledException>();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user