diff --git a/CHANGELOG.md b/CHANGELOG.md
index b35377d..e05311e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+- Add missing methods in `IProjectionBuilder` to enable configuration of projection subscription start options.
+
## [1.10.3] - 2023-09-05
### Added
diff --git a/src/Atc.Cosmos.EventStore.Cqrs/DependencyInjection/IProjectionBuilder.cs b/src/Atc.Cosmos.EventStore.Cqrs/DependencyInjection/IProjectionBuilder.cs
index a3507f2..d4285ab 100644
--- a/src/Atc.Cosmos.EventStore.Cqrs/DependencyInjection/IProjectionBuilder.cs
+++ b/src/Atc.Cosmos.EventStore.Cqrs/DependencyInjection/IProjectionBuilder.cs
@@ -2,16 +2,50 @@
namespace Microsoft.Extensions.DependencyInjection;
+///
+/// Interface for projecting data from a source to a destination.
+///
public interface IProjectionBuilder
{
///
/// Filter on stream id for events projected.
///
/// Filter pattern.
- /// The builder.
+ /// Reference to this instance.
IProjectionBuilder WithFilter(string filter);
+ ///
+ /// Define a job name for the projection.
+ ///
+ /// Job name.
+ /// Reference to this instance.
IProjectionBuilder WithJobName(string name);
+ ///
+ /// Set an exception handler for the projection process.
+ ///
+ /// Handler for process exceptions.
+ /// Reference to this instance.
IProjectionBuilder WithExceptionHandler(ProcessExceptionHandler handler);
+
+ ///
+ /// Indicate the point in time the projection should start from.
+ ///
+ /// Projection start options.
+ /// Reference to this instance.
+ IProjectionBuilder WithProjectionStartsFrom(SubscriptionStartOptions startFrom);
+
+ ///
+ /// Set the polling interval for the projection.
+ ///
+ /// Polling interval.
+ /// Reference to this instance.
+ IProjectionBuilder WithPollingInterval(TimeSpan pollingInterval);
+
+ ///
+ /// Set maximum number of items for the projection.
+ ///
+ /// Maximum items count.
+ /// Reference to this instance.
+ IProjectionBuilder WithMaxItems(int maxItems);
}
\ No newline at end of file
diff --git a/test/Atc.Cosmos.EventStore.Cqrs.Tests/DependencyInjection/Internal/ProjectionBuilderTests.cs b/test/Atc.Cosmos.EventStore.Cqrs.Tests/DependencyInjection/Internal/ProjectionBuilderTests.cs
index 44b71f8..c37e31d 100644
--- a/test/Atc.Cosmos.EventStore.Cqrs.Tests/DependencyInjection/Internal/ProjectionBuilderTests.cs
+++ b/test/Atc.Cosmos.EventStore.Cqrs.Tests/DependencyInjection/Internal/ProjectionBuilderTests.cs
@@ -3,6 +3,7 @@
using Atc.Cosmos.EventStore.Cqrs.Tests.Mocks;
using Atc.Test;
using FluentAssertions;
+using Microsoft.Extensions.DependencyInjection;
using Xunit;
namespace Atc.Cosmos.EventStore.Cqrs.Tests.DependencyInjection.Internal;
@@ -15,7 +16,8 @@ internal void Should_Set_Name(
ProjectionOptions options,
ProjectionBuilder sut)
{
- sut.WithJobName(name);
+ var abstraction = sut as IProjectionBuilder;
+ abstraction.WithJobName(name);
sut.Build(options);
options.Name.Should().Be(name);
@@ -36,14 +38,15 @@ internal void Should_Set_ExceptionHandler(
ProjectionOptions options,
ProjectionBuilder sut)
{
- sut.WithExceptionHandler(handler);
+ var abstraction = sut as IProjectionBuilder;
+ abstraction.WithExceptionHandler(handler);
sut.Build(options);
options.ExceptionHandler.Should().Be(handler);
}
[Theory, AutoNSubstituteData]
- internal void ShouldHave_Default_ExceptionHandler(
+ internal void Should_Have_Default_ExceptionHandler(
ProjectionOptions options,
ProjectionBuilder sut)
{
@@ -51,4 +54,40 @@ internal void ShouldHave_Default_ExceptionHandler(
options.ExceptionHandler.Should().NotBeNull();
}
+
+ [Theory, AutoNSubstituteData]
+ internal void Should_Set_StartFrom(
+ SubscriptionStartOptions startFrom,
+ ProjectionOptions options,
+ ProjectionBuilder sut)
+ {
+ var abstraction = sut as IProjectionBuilder;
+ abstraction.WithProjectionStartsFrom(startFrom);
+ sut.Build(options);
+
+ options.StartsFrom.Should().Be(startFrom);
+ }
+
+ [Theory, AutoNSubstituteData]
+ internal void Should_Have_Default_StartFrom(
+ ProjectionOptions options,
+ ProjectionBuilder sut)
+ {
+ sut.Build(options);
+
+ options.StartsFrom.Should().Be(SubscriptionStartOptions.FromBegining);
+ }
+
+ [Theory, AutoNSubstituteData]
+ internal void Should_Set_PollingInterval(
+ TimeSpan pollingInterval,
+ ProjectionOptions options,
+ ProjectionBuilder sut)
+ {
+ var abstraction = sut as IProjectionBuilder;
+ abstraction.WithPollingInterval(pollingInterval);
+ sut.Build(options);
+
+ options.PollingInterval.Should().Be(pollingInterval);
+ }
}
diff --git a/version.json b/version.json
index 8327a77..a1074ff 100644
--- a/version.json
+++ b/version.json
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
- "version": "1.10",
+ "version": "1.11",
"assemblyVersion": {
"precision": "revision"
},