From 53ec1e69fdc45b4440bb804843af37d48342cf2d Mon Sep 17 00:00:00 2001 From: neuecc Date: Wed, 13 Dec 2023 17:00:55 +0900 Subject: [PATCH] EventFactory -> Event --- sandbox/ConsoleApp1/Program.cs | 2 +- src/R3/Factories/Empty.cs | 2 +- src/R3/Factories/Never.cs | 2 +- src/R3/Factories/Range.cs | 2 +- src/R3/Factories/Repeat.cs | 2 +- src/R3/Factories/Return.cs | 2 +- src/R3/Factories/ReturnOnCompleted.cs | 2 +- src/R3/Factories/Throw.cs | 2 +- src/R3/Factories/Timer.cs | 2 +- src/R3/Factories/ToCompletableEvent.cs | 2 +- src/R3/Factories/ToEvent.cs | 2 +- src/R3/Factories/_EventFactory.cs | 2 +- tests/R3.Tests/FactoryTests/EmptyTest.cs | 4 +- tests/R3.Tests/FactoryTests/NeverTest.cs | 4 +- tests/R3.Tests/FactoryTests/RangeTest.cs | 12 +++--- tests/R3.Tests/FactoryTests/RepeatTest.cs | 8 ++-- .../FactoryTests/ReturnOnCompletedTest.cs | 4 +- tests/R3.Tests/FactoryTests/ReturnTest.cs | 12 +++--- tests/R3.Tests/FactoryTests/ThrowTest.cs | 4 +- tests/R3.Tests/OperatorTests/AggregateTest.cs | 38 +++++++++---------- 20 files changed, 55 insertions(+), 55 deletions(-) diff --git a/sandbox/ConsoleApp1/Program.cs b/sandbox/ConsoleApp1/Program.cs index 864e3456..c2d31425 100644 --- a/sandbox/ConsoleApp1/Program.cs +++ b/sandbox/ConsoleApp1/Program.cs @@ -167,7 +167,7 @@ -//EventFactory.Return(10, TimeProvider.System) +//Event.Return(10, TimeProvider.System) // .WriteLine(); //Console.ReadLine(); diff --git a/src/R3/Factories/Empty.cs b/src/R3/Factories/Empty.cs index a804f8c6..441a196e 100644 --- a/src/R3/Factories/Empty.cs +++ b/src/R3/Factories/Empty.cs @@ -1,6 +1,6 @@ namespace R3 { - public static partial class EventFactory + public static partial class Event { public static CompletableEvent Empty() { diff --git a/src/R3/Factories/Never.cs b/src/R3/Factories/Never.cs index 17eee707..70482f3b 100644 --- a/src/R3/Factories/Never.cs +++ b/src/R3/Factories/Never.cs @@ -1,6 +1,6 @@ namespace R3 { - public static partial class EventFactory + public static partial class Event { // Never public static Event Never() diff --git a/src/R3/Factories/Range.cs b/src/R3/Factories/Range.cs index 3e90f167..5c83b8f4 100644 --- a/src/R3/Factories/Range.cs +++ b/src/R3/Factories/Range.cs @@ -1,6 +1,6 @@ namespace R3 { - public static partial class EventFactory + public static partial class Event { // no scheduler(TimeProvider) overload diff --git a/src/R3/Factories/Repeat.cs b/src/R3/Factories/Repeat.cs index 2d7a26fb..5163f698 100644 --- a/src/R3/Factories/Repeat.cs +++ b/src/R3/Factories/Repeat.cs @@ -1,6 +1,6 @@ namespace R3 { - public static partial class EventFactory + public static partial class Event { // no scheduler(TimeProvider) overload // no infinitely overload diff --git a/src/R3/Factories/Return.cs b/src/R3/Factories/Return.cs index fc4be9a2..92c3202f 100644 --- a/src/R3/Factories/Return.cs +++ b/src/R3/Factories/Return.cs @@ -1,6 +1,6 @@ namespace R3 { - public static partial class EventFactory + public static partial class Event { public static CompletableEvent Return(TMessage value) { diff --git a/src/R3/Factories/ReturnOnCompleted.cs b/src/R3/Factories/ReturnOnCompleted.cs index 196c91bc..36292e85 100644 --- a/src/R3/Factories/ReturnOnCompleted.cs +++ b/src/R3/Factories/ReturnOnCompleted.cs @@ -1,6 +1,6 @@ namespace R3 { - public static partial class EventFactory + public static partial class Event { // similar as Empty, only return OnCompleted diff --git a/src/R3/Factories/Throw.cs b/src/R3/Factories/Throw.cs index e6feb37b..5b99f312 100644 --- a/src/R3/Factories/Throw.cs +++ b/src/R3/Factories/Throw.cs @@ -1,6 +1,6 @@ namespace R3 { - public static partial class EventFactory + public static partial class Event { public static CompletableEvent> Throw(Exception exception) { diff --git a/src/R3/Factories/Timer.cs b/src/R3/Factories/Timer.cs index 0b09e242..71a87686 100644 --- a/src/R3/Factories/Timer.cs +++ b/src/R3/Factories/Timer.cs @@ -1,6 +1,6 @@ namespace R3 { - public static partial class EventFactory + public static partial class Event { public static CompletableEvent Timer(TimeSpan dueTime, TimeProvider timeProvider) { diff --git a/src/R3/Factories/ToCompletableEvent.cs b/src/R3/Factories/ToCompletableEvent.cs index 7571f917..9f787f5c 100644 --- a/src/R3/Factories/ToCompletableEvent.cs +++ b/src/R3/Factories/ToCompletableEvent.cs @@ -1,6 +1,6 @@ namespace R3 { - public static partial class EventFactory + public static partial class Event { public static CompletableEvent> ToCompletableEvent(this Task task) { diff --git a/src/R3/Factories/ToEvent.cs b/src/R3/Factories/ToEvent.cs index 20c9bcce..c4bff8a9 100644 --- a/src/R3/Factories/ToEvent.cs +++ b/src/R3/Factories/ToEvent.cs @@ -1,6 +1,6 @@ namespace R3 { - public static partial class EventFactory + public static partial class Event { public static CompletableEvent ToEvent(this IEnumerable source) { diff --git a/src/R3/Factories/_EventFactory.cs b/src/R3/Factories/_EventFactory.cs index 0bd82e12..092bc5a5 100644 --- a/src/R3/Factories/_EventFactory.cs +++ b/src/R3/Factories/_EventFactory.cs @@ -3,7 +3,7 @@ namespace R3 { - public static partial class EventFactory + public static partial class Event { // TODO: this is working space, will remove this file after complete. diff --git a/tests/R3.Tests/FactoryTests/EmptyTest.cs b/tests/R3.Tests/FactoryTests/EmptyTest.cs index f02592e9..36f41e96 100644 --- a/tests/R3.Tests/FactoryTests/EmptyTest.cs +++ b/tests/R3.Tests/FactoryTests/EmptyTest.cs @@ -7,7 +7,7 @@ public class EmptyTest [Fact] public void Empty() { - using var list = EventFactory.Empty().ToLiveList(); + using var list = Event.Empty().ToLiveList(); list.AssertIsCompleted(); } @@ -15,7 +15,7 @@ public void Empty() public void EmptyWithTime() { var fakeTime = new FakeTimeProvider(); - using var list = EventFactory.Empty(TimeSpan.FromSeconds(5), fakeTime).ToLiveList(); + using var list = Event.Empty(TimeSpan.FromSeconds(5), fakeTime).ToLiveList(); fakeTime.Advance(TimeSpan.FromSeconds(4)); list.AssertIsNotCompleted(); diff --git a/tests/R3.Tests/FactoryTests/NeverTest.cs b/tests/R3.Tests/FactoryTests/NeverTest.cs index e03598b9..480ae920 100644 --- a/tests/R3.Tests/FactoryTests/NeverTest.cs +++ b/tests/R3.Tests/FactoryTests/NeverTest.cs @@ -5,7 +5,7 @@ public class NeverTest [Fact] public void Never() { - using var list = EventFactory.Never().ToLiveList(); + using var list = Event.Never().ToLiveList(); list.AssertEqual([]); } @@ -13,7 +13,7 @@ public void Never() [Fact] public void NeverComplete() { - using var list = EventFactory.NeverComplete().ToLiveList(); + using var list = Event.NeverComplete().ToLiveList(); list.AssertIsNotCompleted(); } } diff --git a/tests/R3.Tests/FactoryTests/RangeTest.cs b/tests/R3.Tests/FactoryTests/RangeTest.cs index 1c3a8158..4e4dc6d5 100644 --- a/tests/R3.Tests/FactoryTests/RangeTest.cs +++ b/tests/R3.Tests/FactoryTests/RangeTest.cs @@ -7,23 +7,23 @@ public class RangeTest [Fact] public void Range() { - using var list1 = EventFactory.Range(5, 8).ToLiveList(); + using var list1 = Event.Range(5, 8).ToLiveList(); list1.AssertEqual([5, 6, 7, 8, 9, 10, 11, 12]); list1.AssertIsCompleted(); - using var list2 = EventFactory.Range(20, 3).ToLiveList(); + using var list2 = Event.Range(20, 3).ToLiveList(); list2.AssertEqual([20, 21, 22]); list2.AssertIsCompleted(); - using var list3 = EventFactory.Range(-3, 5).ToLiveList(); + using var list3 = Event.Range(-3, 5).ToLiveList(); list3.AssertEqual([-3, -2, -1, 0, 1]); list3.AssertIsCompleted(); - using var list4 = EventFactory.Range(10, 0).ToLiveList(); + using var list4 = Event.Range(10, 0).ToLiveList(); list4.AssertEqual([]); list4.AssertIsCompleted(); - Assert.Throws(() => EventFactory.Range(10, -1)); + Assert.Throws(() => Event.Range(10, -1)); } [Fact] @@ -31,7 +31,7 @@ public void Stop() { var cts = new CancellationTokenSource(); - using var list = EventFactory.Range(0, int.MaxValue, cts.Token) + using var list = Event.Range(0, int.MaxValue, cts.Token) .Take(5) .DoOnCompleted(() => cts.Cancel()) .ToLiveList(); diff --git a/tests/R3.Tests/FactoryTests/RepeatTest.cs b/tests/R3.Tests/FactoryTests/RepeatTest.cs index eb9fee05..c042832d 100644 --- a/tests/R3.Tests/FactoryTests/RepeatTest.cs +++ b/tests/R3.Tests/FactoryTests/RepeatTest.cs @@ -6,15 +6,15 @@ public class RepeatTest [Fact] public void Repeat() { - using var list = EventFactory.Repeat("foo", 3).ToLiveList(); + using var list = Event.Repeat("foo", 3).ToLiveList(); list.AssertEqual(["foo", "foo", "foo"]); list.AssertIsCompleted(); - using var list2 = EventFactory.Repeat("foo", 0).ToLiveList(); + using var list2 = Event.Repeat("foo", 0).ToLiveList(); list2.AssertEqual([]); list2.AssertIsCompleted(); - Assert.Throws(() => EventFactory.Repeat("foo", -1)); + Assert.Throws(() => Event.Repeat("foo", -1)); } [Fact] @@ -22,7 +22,7 @@ public void Stop() { var cts = new CancellationTokenSource(); - using var list = EventFactory.Repeat("foo", int.MaxValue, cts.Token) + using var list = Event.Repeat("foo", int.MaxValue, cts.Token) .Take(5) .DoOnCompleted(() => cts.Cancel()) .ToLiveList(); diff --git a/tests/R3.Tests/FactoryTests/ReturnOnCompletedTest.cs b/tests/R3.Tests/FactoryTests/ReturnOnCompletedTest.cs index 8bb9173d..8210d57b 100644 --- a/tests/R3.Tests/FactoryTests/ReturnOnCompletedTest.cs +++ b/tests/R3.Tests/FactoryTests/ReturnOnCompletedTest.cs @@ -8,7 +8,7 @@ public class ReturnOnCompletedTest public void ReturnOnCompleted() { { - using var list = EventFactory.ReturnOnCompleted("foo").ToLiveList(); + using var list = Event.ReturnOnCompleted("foo").ToLiveList(); list.AssertEqual([]); list.AssertIsCompleted(); list.AssertCompletedValue("foo"); @@ -16,7 +16,7 @@ public void ReturnOnCompleted() { var fakeTime = new FakeTimeProvider(); - using var list = EventFactory.ReturnOnCompleted("foo", TimeSpan.FromSeconds(5), fakeTime).ToLiveList(); + using var list = Event.ReturnOnCompleted("foo", TimeSpan.FromSeconds(5), fakeTime).ToLiveList(); fakeTime.Advance(TimeSpan.FromSeconds(4)); list.AssertEqual([]); diff --git a/tests/R3.Tests/FactoryTests/ReturnTest.cs b/tests/R3.Tests/FactoryTests/ReturnTest.cs index dbbc2101..71cd52a5 100644 --- a/tests/R3.Tests/FactoryTests/ReturnTest.cs +++ b/tests/R3.Tests/FactoryTests/ReturnTest.cs @@ -8,21 +8,21 @@ public class ReturnTest public void Return() { { - using var list = EventFactory.Return(10).ToLiveList(); + using var list = Event.Return(10).ToLiveList(); list.AssertEqual([10]); list.AssertIsCompleted(); } { var fakeTime = new FakeTimeProvider(); - using var list = EventFactory.Return(10, TimeSpan.Zero, fakeTime).ToLiveList(); + using var list = Event.Return(10, TimeSpan.Zero, fakeTime).ToLiveList(); list.AssertEqual([10]); list.AssertIsCompleted(); } { var fakeTime = new FakeTimeProvider(); - using var list = EventFactory.Return(10, TimeSpan.FromSeconds(5), fakeTime).ToLiveList(); + using var list = Event.Return(10, TimeSpan.FromSeconds(5), fakeTime).ToLiveList(); list.AssertEqual([]); fakeTime.Advance(TimeSpan.FromSeconds(4)); @@ -38,7 +38,7 @@ public void Return() [Fact] public void ReturnThreadPoolScheduleOptimized() { - using var list = EventFactory.Return(10).ToLiveList(); + using var list = Event.Return(10).ToLiveList(); Thread.Sleep(1); @@ -51,7 +51,7 @@ public void ReturnThreadPoolScheduleOptimized() public void ReturnOnCompleted() { { - using var list = EventFactory.Return(0, "foo").ToLiveList(); + using var list = Event.Return(0, "foo").ToLiveList(); list.AssertEqual([0]); list.AssertIsCompleted(); list.AssertCompletedValue("foo"); @@ -59,7 +59,7 @@ public void ReturnOnCompleted() { var fakeTime = new FakeTimeProvider(); - using var list = EventFactory.Return(10, "foo", TimeSpan.FromSeconds(5), fakeTime).ToLiveList(); + using var list = Event.Return(10, "foo", TimeSpan.FromSeconds(5), fakeTime).ToLiveList(); list.AssertEqual([]); fakeTime.Advance(TimeSpan.FromSeconds(4)); diff --git a/tests/R3.Tests/FactoryTests/ThrowTest.cs b/tests/R3.Tests/FactoryTests/ThrowTest.cs index ddbc9267..5800870f 100644 --- a/tests/R3.Tests/FactoryTests/ThrowTest.cs +++ b/tests/R3.Tests/FactoryTests/ThrowTest.cs @@ -8,7 +8,7 @@ public void Throw() { { var e = new Exception(); - using var list = EventFactory.Throw(e).ToLiveList(); + using var list = Event.Throw(e).ToLiveList(); list.AssertEqual([]); list.CompletedValue.IsFailure.Should().BeTrue(); list.CompletedValue.Exception.Should().Be(e); @@ -17,7 +17,7 @@ public void Throw() var fakeTime = new FakeTimeProvider(); var e = new Exception(); - using var list = EventFactory.Throw(e, TimeSpan.FromSeconds(5), fakeTime).ToLiveList(); + using var list = Event.Throw(e, TimeSpan.FromSeconds(5), fakeTime).ToLiveList(); fakeTime.Advance(TimeSpan.FromSeconds(4)); list.AssertEqual([]); diff --git a/tests/R3.Tests/OperatorTests/AggregateTest.cs b/tests/R3.Tests/OperatorTests/AggregateTest.cs index 80ce594e..5e0506c5 100644 --- a/tests/R3.Tests/OperatorTests/AggregateTest.cs +++ b/tests/R3.Tests/OperatorTests/AggregateTest.cs @@ -27,7 +27,7 @@ public async Task Aggreagte() [Fact] public async Task ImmediateCompleted() { - var range = EventFactory.Range(1, 5); + var range = Event.Range(1, 5); var listTask = range.AggregateAsync(new List(), (x, i) => { x.Add(i); return x; }, (x, _) => x); (await listTask).Should().Equal(1, 2, 3, 4, 5); } @@ -70,7 +70,7 @@ public async Task Count() count.Should().Be(8); - var count2 = await EventFactory.Empty().CountAsync(); + var count2 = await Event.Empty().CountAsync(); count2.Should().Be(0); } @@ -82,10 +82,10 @@ public async Task LongCount() count.Should().Be(8); - var count2 = await EventFactory.Empty().LongCountAsync(); + var count2 = await Event.Empty().LongCountAsync(); count2.Should().Be(0); - var error = EventFactory.Throw(new Exception("foo")); + var error = Event.Throw(new Exception("foo")); await Assert.ThrowsAsync(async () => await error.LongCountAsync()); } @@ -98,13 +98,13 @@ public async Task Min() min.Should().Be(1); - (await EventFactory.Return(999).MinAsync()).Should().Be(999); + (await Event.Return(999).MinAsync()).Should().Be(999); - var task = EventFactory.Empty().MinAsync(); + var task = Event.Empty().MinAsync(); await Assert.ThrowsAsync(async () => await task); - var error = EventFactory.Range(1, 10).Select(x => + var error = Event.Range(1, 10).Select(x => { if (x == 3) throw new Exception("foo"); return x; @@ -120,13 +120,13 @@ public async Task Max() min.Should().Be(10); - (await EventFactory.Return(999).MaxAsync()).Should().Be(999); + (await Event.Return(999).MaxAsync()).Should().Be(999); - var task = EventFactory.Empty().MaxAsync(); + var task = Event.Empty().MaxAsync(); await Assert.ThrowsAsync(async () => await task); - var error = EventFactory.Range(1, 10).Select(x => + var error = Event.Range(1, 10).Select(x => { if (x == 3) throw new Exception("foo"); return x; @@ -143,15 +143,15 @@ public async Task MinMax() minmax.Min.Should().Be(1); minmax.Max.Should().Be(10); - var mm2 = await EventFactory.Return(999).MinMaxAsync(); + var mm2 = await Event.Return(999).MinMaxAsync(); mm2.Min.Should().Be(999); mm2.Max.Should().Be(999); - var task = EventFactory.Empty().MaxAsync(); + var task = Event.Empty().MaxAsync(); await Assert.ThrowsAsync(async () => await task); - var error = EventFactory.Range(1, 10).Select(x => + var error = Event.Range(1, 10).Select(x => { if (x == 3) throw new Exception("foo"); return x; @@ -167,12 +167,12 @@ public async Task Sum() sum.Should().Be(36); - (await EventFactory.Return(999).SumAsync()).Should().Be(999); + (await Event.Return(999).SumAsync()).Should().Be(999); - var task = EventFactory.Empty().SumAsync(); + var task = Event.Empty().SumAsync(); (await task).Should().Be(0); - var error = EventFactory.Range(1, 10).Select(x => + var error = Event.Range(1, 10).Select(x => { if (x == 3) throw new Exception("foo"); return x; @@ -188,12 +188,12 @@ public async Task Avg() avg.Should().Be(new int[] { 1, 10, 1, 3, 4, 6, 7, 4 }.Average()); - (await EventFactory.Return(999).AverageAsync()).Should().Be(999); + (await Event.Return(999).AverageAsync()).Should().Be(999); - var task = EventFactory.Empty().AverageAsync(); + var task = Event.Empty().AverageAsync(); await Assert.ThrowsAsync(async () => await task); - var error = EventFactory.Range(1, 10).Select(x => + var error = Event.Range(1, 10).Select(x => { if (x == 3) throw new Exception("foo"); return x;