Skip to content

Commit

Permalink
EventFactory -> Event
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Dec 13, 2023
1 parent e9802cf commit 53ec1e6
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion sandbox/ConsoleApp1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@



//EventFactory.Return(10, TimeProvider.System)
//Event.Return(10, TimeProvider.System)
// .WriteLine();

//Console.ReadLine();
Expand Down
2 changes: 1 addition & 1 deletion src/R3/Factories/Empty.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace R3
{
public static partial class EventFactory
public static partial class Event
{
public static CompletableEvent<TMessage, Unit> Empty<TMessage>()
{
Expand Down
2 changes: 1 addition & 1 deletion src/R3/Factories/Never.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace R3
{
public static partial class EventFactory
public static partial class Event
{
// Never
public static Event<T> Never<T>()
Expand Down
2 changes: 1 addition & 1 deletion src/R3/Factories/Range.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace R3
{
public static partial class EventFactory
public static partial class Event
{
// no scheduler(TimeProvider) overload

Expand Down
2 changes: 1 addition & 1 deletion src/R3/Factories/Repeat.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace R3
{
public static partial class EventFactory
public static partial class Event
{
// no scheduler(TimeProvider) overload
// no infinitely overload
Expand Down
2 changes: 1 addition & 1 deletion src/R3/Factories/Return.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace R3
{
public static partial class EventFactory
public static partial class Event
{
public static CompletableEvent<TMessage, Unit> Return<TMessage>(TMessage value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/R3/Factories/ReturnOnCompleted.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace R3
{
public static partial class EventFactory
public static partial class Event
{
// similar as Empty, only return OnCompleted

Expand Down
2 changes: 1 addition & 1 deletion src/R3/Factories/Throw.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace R3
{
public static partial class EventFactory
public static partial class Event
{
public static CompletableEvent<TMessage, Result<Unit>> Throw<TMessage>(Exception exception)
{
Expand Down
2 changes: 1 addition & 1 deletion src/R3/Factories/Timer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace R3
{
public static partial class EventFactory
public static partial class Event
{
public static CompletableEvent<Unit, Unit> Timer(TimeSpan dueTime, TimeProvider timeProvider)
{
Expand Down
2 changes: 1 addition & 1 deletion src/R3/Factories/ToCompletableEvent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace R3
{
public static partial class EventFactory
public static partial class Event
{
public static CompletableEvent<TMessage, Result<Unit>> ToCompletableEvent<TMessage>(this Task<TMessage> task)
{
Expand Down
2 changes: 1 addition & 1 deletion src/R3/Factories/ToEvent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace R3
{
public static partial class EventFactory
public static partial class Event
{
public static CompletableEvent<TMessage, Unit> ToEvent<TMessage>(this IEnumerable<TMessage> source)
{
Expand Down
2 changes: 1 addition & 1 deletion src/R3/Factories/_EventFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions tests/R3.Tests/FactoryTests/EmptyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ public class EmptyTest
[Fact]
public void Empty()
{
using var list = EventFactory.Empty<int>().ToLiveList();
using var list = Event.Empty<int>().ToLiveList();
list.AssertIsCompleted();
}

[Fact]
public void EmptyWithTime()
{
var fakeTime = new FakeTimeProvider();
using var list = EventFactory.Empty<int>(TimeSpan.FromSeconds(5), fakeTime).ToLiveList();
using var list = Event.Empty<int>(TimeSpan.FromSeconds(5), fakeTime).ToLiveList();

fakeTime.Advance(TimeSpan.FromSeconds(4));
list.AssertIsNotCompleted();
Expand Down
4 changes: 2 additions & 2 deletions tests/R3.Tests/FactoryTests/NeverTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ public class NeverTest
[Fact]
public void Never()
{
using var list = EventFactory.Never<int>().ToLiveList();
using var list = Event.Never<int>().ToLiveList();
list.AssertEqual([]);
}

// NeverComplete test
[Fact]
public void NeverComplete()
{
using var list = EventFactory.NeverComplete<int, int>().ToLiveList();
using var list = Event.NeverComplete<int, int>().ToLiveList();
list.AssertIsNotCompleted();
}
}
12 changes: 6 additions & 6 deletions tests/R3.Tests/FactoryTests/RangeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ 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<ArgumentOutOfRangeException>(() => EventFactory.Range(10, -1));
Assert.Throws<ArgumentOutOfRangeException>(() => Event.Range(10, -1));
}

[Fact]
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();
Expand Down
8 changes: 4 additions & 4 deletions tests/R3.Tests/FactoryTests/RepeatTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ 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<ArgumentOutOfRangeException>(() => EventFactory.Repeat("foo", -1));
Assert.Throws<ArgumentOutOfRangeException>(() => Event.Repeat("foo", -1));
}

[Fact]
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();
Expand Down
4 changes: 2 additions & 2 deletions tests/R3.Tests/FactoryTests/ReturnOnCompletedTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ public class ReturnOnCompletedTest
public void ReturnOnCompleted()
{
{
using var list = EventFactory.ReturnOnCompleted<int, string>("foo").ToLiveList();
using var list = Event.ReturnOnCompleted<int, string>("foo").ToLiveList();
list.AssertEqual([]);
list.AssertIsCompleted();
list.AssertCompletedValue("foo");
}
{
var fakeTime = new FakeTimeProvider();

using var list = EventFactory.ReturnOnCompleted<int, string>("foo", TimeSpan.FromSeconds(5), fakeTime).ToLiveList();
using var list = Event.ReturnOnCompleted<int, string>("foo", TimeSpan.FromSeconds(5), fakeTime).ToLiveList();

fakeTime.Advance(TimeSpan.FromSeconds(4));
list.AssertEqual([]);
Expand Down
12 changes: 6 additions & 6 deletions tests/R3.Tests/FactoryTests/ReturnTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);

Expand All @@ -51,15 +51,15 @@ 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");
}
{
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));
Expand Down
4 changes: 2 additions & 2 deletions tests/R3.Tests/FactoryTests/ThrowTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public void Throw()
{
{
var e = new Exception();
using var list = EventFactory.Throw<int>(e).ToLiveList();
using var list = Event.Throw<int>(e).ToLiveList();
list.AssertEqual([]);
list.CompletedValue.IsFailure.Should().BeTrue();
list.CompletedValue.Exception.Should().Be(e);
Expand All @@ -17,7 +17,7 @@ public void Throw()
var fakeTime = new FakeTimeProvider();

var e = new Exception();
using var list = EventFactory.Throw<int>(e, TimeSpan.FromSeconds(5), fakeTime).ToLiveList();
using var list = Event.Throw<int>(e, TimeSpan.FromSeconds(5), fakeTime).ToLiveList();

fakeTime.Advance(TimeSpan.FromSeconds(4));
list.AssertEqual([]);
Expand Down
Loading

0 comments on commit 53ec1e6

Please sign in to comment.