mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-16 03:50:11 +00:00
45 lines
985 B
C#
45 lines
985 B
C#
|
|
using Cysharp.Threading.Tasks;
|
|||
|
|
using Cysharp.Threading.Tasks.Linq;
|
|||
|
|
using FluentAssertions;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using Xunit;
|
|||
|
|
|
|||
|
|
namespace NetCoreTests.Linq
|
|||
|
|
{
|
|||
|
|
public class TakeInfinityTest
|
|||
|
|
{
|
|||
|
|
[Fact]
|
|||
|
|
public async Task Take()
|
|||
|
|
{
|
|||
|
|
var rp = new AsyncReactiveProperty<int>(1);
|
|||
|
|
|
|||
|
|
var xs = rp.Take(5).ToArrayAsync();
|
|||
|
|
|
|||
|
|
rp.Value = 2;
|
|||
|
|
rp.Value = 3;
|
|||
|
|
rp.Value = 4;
|
|||
|
|
rp.Value = 5;
|
|||
|
|
|
|||
|
|
(await xs).Should().BeEquivalentTo(1, 2, 3, 4, 5);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[Fact]
|
|||
|
|
public async Task TakeWhile()
|
|||
|
|
{
|
|||
|
|
var rp = new AsyncReactiveProperty<int>(1);
|
|||
|
|
|
|||
|
|
var xs = rp.TakeWhile(x => x != 5).ToArrayAsync();
|
|||
|
|
|
|||
|
|
rp.Value = 2;
|
|||
|
|
rp.Value = 3;
|
|||
|
|
rp.Value = 4;
|
|||
|
|
rp.Value = 5;
|
|||
|
|
|
|||
|
|
(await xs).Should().BeEquivalentTo(1, 2, 3, 4);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|