Files
R3/tests/R3.Tests/OperatorTests/SynchronizationTest.cs
2024-01-01 23:25:54 +09:00

21 lines
489 B
C#

namespace R3.Tests.OperatorTests;
public class SynchronizationTest(ITestOutputHelper output)
{
[Fact]
public void Test()
{
var subject = new Subject<int>();
var count = 0;
var no_sync = 0;
subject.Subscribe(x => no_sync++);
subject.Synchronize().Subscribe(x => count++);
Parallel.For(0, 100, x => subject.OnNext(x));
count.Should().Be(100);
output.WriteLine($"Count: {count}, no_sync: {no_sync}");
}
}