-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
222 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test/Kurrent.Client.Tests/Projections/DisableProjectionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Kurrent.Client.Tests.TestNode; | ||
|
||
namespace Kurrent.Client.Tests.Projections; | ||
|
||
public class DisableProjectionTests(ITestOutputHelper output, DisableProjectionTests.CustomFixture fixture) | ||
: KurrentTemporaryTests<DisableProjectionTests.CustomFixture>(output, fixture) { | ||
[Fact] | ||
public async Task disable_projection() { | ||
var name = Names.First(); | ||
await Fixture.Projections.DisableAsync(name, userCredentials: TestCredentials.Root); | ||
var result = await Fixture.Projections.GetStatusAsync(name, userCredentials: TestCredentials.Root); | ||
Assert.NotNull(result); | ||
Assert.Contains(["Aborted/Stopped", "Stopped"], x => x == result!.Status); | ||
} | ||
|
||
static readonly string[] Names = ["$streams", "$stream_by_category", "$by_category", "$by_event_type", "$by_correlation_id"]; | ||
|
||
public class CustomFixture : KurrentTemporaryFixture { | ||
public CustomFixture() : base(x => x.RunProjections()) { } | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
test/Kurrent.Client.Tests/Projections/EnableProjectionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Kurrent.Client.Tests.TestNode; | ||
|
||
namespace Kurrent.Client.Tests.Projections; | ||
|
||
public class EnableProjectionTests(ITestOutputHelper output, EnableProjectionTests.CustomFixture fixture) | ||
: KurrentTemporaryTests<EnableProjectionTests.CustomFixture>(output, fixture) { | ||
[Fact] | ||
public async Task enable_projection() { | ||
var name = Names.First(); | ||
await Fixture.Projections.EnableAsync(name, userCredentials: TestCredentials.Root); | ||
var result = await Fixture.Projections.GetStatusAsync(name, userCredentials: TestCredentials.Root); | ||
Assert.NotNull(result); | ||
Assert.Equal("Running", result.Status); | ||
} | ||
|
||
static readonly string[] Names = ["$streams", "$stream_by_category", "$by_category", "$by_event_type", "$by_correlation_id"]; | ||
|
||
public class CustomFixture : KurrentTemporaryFixture { | ||
public CustomFixture() : base(x => x.RunProjections()) { } | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
test/Kurrent.Client.Tests/Projections/GetProjectionResultTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using EventStore.Client; | ||
using Kurrent.Client.Tests.TestNode; | ||
|
||
namespace Kurrent.Client.Tests.Projections; | ||
|
||
public class GetProjectionResultTests(ITestOutputHelper output, GetProjectionResultTests.CustomFixture fixture) | ||
: KurrentTemporaryTests<GetProjectionResultTests.CustomFixture>(output, fixture) { | ||
[Fact] | ||
public async Task get_result() { | ||
var name = Fixture.GetProjectionName(); | ||
Result? result = null; | ||
|
||
var projection = $$""" | ||
fromStream('{{name}}').when({ | ||
"$init": function() { return { Count: 0 }; }, | ||
"$any": function(s, e) { s.Count++; return s; } | ||
}); | ||
"""; | ||
|
||
await Fixture.Projections.CreateContinuousAsync( | ||
name, | ||
projection, | ||
userCredentials: TestCredentials.Root | ||
); | ||
|
||
await Fixture.Streams.AppendToStreamAsync( | ||
name, | ||
StreamState.NoStream, | ||
Fixture.CreateTestEvents() | ||
); | ||
|
||
await AssertEx.IsOrBecomesTrue( | ||
async () => { | ||
result = await Fixture.Projections.GetResultAsync<Result>(name, userCredentials: TestCredentials.Root); | ||
return result.Count > 0; | ||
} | ||
); | ||
|
||
Assert.NotNull(result); | ||
Assert.Equal(1, result!.Count); | ||
} | ||
|
||
record Result { | ||
public int Count { get; set; } | ||
} | ||
|
||
public class CustomFixture : KurrentTemporaryFixture { | ||
public CustomFixture() : base(x => x.RunProjections()) { } | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
test/Kurrent.Client.Tests/Projections/GetProjectionStateTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using EventStore.Client; | ||
using Kurrent.Client.Tests.TestNode; | ||
|
||
namespace Kurrent.Client.Tests.Projections; | ||
|
||
public class GetProjectionStateTests(ITestOutputHelper output, GetProjectionStateTests.CustomFixture fixture) | ||
: KurrentTemporaryTests<GetProjectionStateTests.CustomFixture>(output, fixture) { | ||
[Fact] | ||
public async Task get_state() { | ||
var name = Fixture.GetProjectionName(); | ||
|
||
var projection = $$""" | ||
fromStream('{{name}}').when({ | ||
"$init": function() { return { Count: 0 }; }, | ||
"$any": function(s, e) { s.Count++; return s; } | ||
}); | ||
"""; | ||
|
||
Result? result = null; | ||
|
||
await Fixture.Projections.CreateContinuousAsync( | ||
name, | ||
projection, | ||
userCredentials: TestCredentials.Root | ||
); | ||
|
||
await Fixture.Streams.AppendToStreamAsync( | ||
name, | ||
StreamState.NoStream, | ||
Fixture.CreateTestEvents() | ||
); | ||
|
||
await AssertEx.IsOrBecomesTrue( | ||
async () => { | ||
result = await Fixture.Projections.GetStateAsync<Result>(name, userCredentials: TestCredentials.Root); | ||
return result.Count > 0; | ||
} | ||
); | ||
|
||
Assert.NotNull(result); | ||
Assert.Equal(1, result!.Count); | ||
} | ||
|
||
record Result { | ||
public int Count { get; set; } | ||
} | ||
|
||
public class CustomFixture : KurrentTemporaryFixture { | ||
public CustomFixture() : base(x => x.RunProjections()) { } | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
test/Kurrent.Client.Tests/Projections/GetProjectionStatusTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Kurrent.Client.Tests.TestNode; | ||
|
||
namespace Kurrent.Client.Tests.Projections; | ||
|
||
public class GetProjectionStatusTests(ITestOutputHelper output, GetProjectionStatusTests.CustomFixture fixture) | ||
: KurrentTemporaryTests<GetProjectionStatusTests.CustomFixture>(output, fixture) { | ||
[Fact] | ||
public async Task get_status() { | ||
var name = Names.First(); | ||
var result = await Fixture.Projections.GetStatusAsync(name, userCredentials: TestCredentials.Root); | ||
|
||
Assert.NotNull(result); | ||
Assert.Equal(name, result.Name); | ||
} | ||
|
||
static readonly string[] Names = ["$streams", "$stream_by_category", "$by_category", "$by_event_type", "$by_correlation_id"]; | ||
|
||
public class CustomFixture : KurrentTemporaryFixture { | ||
public CustomFixture() : base(x => x.RunProjections()) { } | ||
} | ||
} |
Oops, something went wrong.