feat: add inital in memory dispatcher
Add a simple in memory dispatcher for scalar requests and stream request.
This commit is contained in:
commit
1218d3617a
145 changed files with 6388 additions and 0 deletions
19
src/request.tests/_fixtures/AmbiguousScalarHandler.cs
Normal file
19
src/request.tests/_fixtures/AmbiguousScalarHandler.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class AmbiguousScalarHandler : IScalarRequestHandler<AmbiguousScalarRequest, string>
|
||||
{
|
||||
// Public method with the same name and signature
|
||||
public Task<string> HandleAsync(AmbiguousScalarRequest request, CancellationToken ct)
|
||||
{
|
||||
return Task.FromResult("Public-Handled");
|
||||
}
|
||||
|
||||
// Explicit interface implementation
|
||||
Task<string> IScalarRequestHandler<AmbiguousScalarRequest, string>.HandleAsync(AmbiguousScalarRequest request, CancellationToken ct)
|
||||
{
|
||||
return Task.FromResult("Interface-Handled");
|
||||
}
|
||||
}
|
||||
8
src/request.tests/_fixtures/AmbiguousScalarRequest.cs
Normal file
8
src/request.tests/_fixtures/AmbiguousScalarRequest.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class AmbiguousScalarRequest : IScalarRequest<string>
|
||||
{
|
||||
}
|
||||
19
src/request.tests/_fixtures/AmbiguousStreamHandler.cs
Normal file
19
src/request.tests/_fixtures/AmbiguousStreamHandler.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class AmbiguousStreamHandler : IStreamRequestHandler<AmbiguousStreamRequest, string>
|
||||
{
|
||||
// Public method with the same name and signature
|
||||
public async IAsyncEnumerable<string> HandleAsync(AmbiguousStreamRequest request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
yield return "Public-Handled";
|
||||
}
|
||||
|
||||
// Explicit interface implementation
|
||||
async IAsyncEnumerable<string> IStreamRequestHandler<AmbiguousStreamRequest, string>.HandleAsync(AmbiguousStreamRequest request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
yield return "Interface-Handled";
|
||||
}
|
||||
}
|
||||
8
src/request.tests/_fixtures/AmbiguousStreamRequest.cs
Normal file
8
src/request.tests/_fixtures/AmbiguousStreamRequest.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class AmbiguousStreamRequest : IStreamRequest<string>
|
||||
{
|
||||
}
|
||||
9
src/request.tests/_fixtures/AnotherNamedScalarRequest.cs
Normal file
9
src/request.tests/_fixtures/AnotherNamedScalarRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class AnotherNamedScalarRequest : INamedScalarRequest
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
9
src/request.tests/_fixtures/AnotherNamedStreamRequest.cs
Normal file
9
src/request.tests/_fixtures/AnotherNamedStreamRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class AnotherNamedStreamRequest : INamedStreamRequest
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
12
src/request.tests/_fixtures/AnotherTestHandler.cs
Normal file
12
src/request.tests/_fixtures/AnotherTestHandler.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
internal sealed class AnotherTestHandler : IScalarRequestHandler<AnotherTestRequest, string>
|
||||
{
|
||||
public Task<string> HandleAsync(AnotherTestRequest request, CancellationToken ct)
|
||||
{
|
||||
return Task.FromResult("ok");
|
||||
}
|
||||
}
|
||||
6
src/request.tests/_fixtures/AnotherTestRequest.cs
Normal file
6
src/request.tests/_fixtures/AnotherTestRequest.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
internal sealed class AnotherTestRequest : IScalarRequest<string> { }
|
||||
10
src/request.tests/_fixtures/BaseScalarHandler.cs
Normal file
10
src/request.tests/_fixtures/BaseScalarHandler.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public abstract class BaseScalarHandler<TRequest> : IScalarRequestHandler<TRequest, string>
|
||||
where TRequest : IScalarRequest<string>
|
||||
{
|
||||
public abstract Task<string> HandleAsync(TRequest request, CancellationToken cancellationToken);
|
||||
}
|
||||
10
src/request.tests/_fixtures/BaseStreamHandler.cs
Normal file
10
src/request.tests/_fixtures/BaseStreamHandler.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public abstract class BaseStreamHandler<TRequest> : IStreamRequestHandler<TRequest, string>
|
||||
where TRequest : IStreamRequest<string>
|
||||
{
|
||||
public abstract IAsyncEnumerable<string> HandleAsync(TRequest request, CancellationToken cancellationToken);
|
||||
}
|
||||
13
src/request.tests/_fixtures/ConstrainedScalarHandler.cs
Normal file
13
src/request.tests/_fixtures/ConstrainedScalarHandler.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ConstrainedScalarHandler<TRequest> : IScalarRequestHandler<TRequest, string>
|
||||
where TRequest : ConstrainedScalarRequest
|
||||
{
|
||||
public Task<string> HandleAsync(TRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult($"{request.Value}-Constrained");
|
||||
}
|
||||
}
|
||||
9
src/request.tests/_fixtures/ConstrainedScalarRequest.cs
Normal file
9
src/request.tests/_fixtures/ConstrainedScalarRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ConstrainedScalarRequest : IScalarRequest<string>
|
||||
{
|
||||
public int Value { get; set; }
|
||||
}
|
||||
14
src/request.tests/_fixtures/ConstrainedStreamHandler.cs
Normal file
14
src/request.tests/_fixtures/ConstrainedStreamHandler.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ConstrainedStreamHandler<TRequest> : IStreamRequestHandler<TRequest, string>
|
||||
where TRequest : ConstrainedStreamRequest
|
||||
{
|
||||
public async IAsyncEnumerable<string> HandleAsync(TRequest request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
yield return $"{request.Value}-Constrained-0";
|
||||
yield return $"{request.Value}-Constrained-1";
|
||||
}
|
||||
}
|
||||
9
src/request.tests/_fixtures/ConstrainedStreamRequest.cs
Normal file
9
src/request.tests/_fixtures/ConstrainedStreamRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ConstrainedStreamRequest : IStreamRequest<string>
|
||||
{
|
||||
public int Value { get; set; }
|
||||
}
|
||||
9
src/request.tests/_fixtures/DeepDerivedScalarRequest.cs
Normal file
9
src/request.tests/_fixtures/DeepDerivedScalarRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class DeepDerivedScalarRequest : InheritedScalarRequest
|
||||
{
|
||||
public int DeepValue { get; set; }
|
||||
}
|
||||
9
src/request.tests/_fixtures/DeepDerivedStreamRequest.cs
Normal file
9
src/request.tests/_fixtures/DeepDerivedStreamRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class DeepDerivedStreamRequest : InheritedStreamRequest
|
||||
{
|
||||
public int DeepValue { get; set; }
|
||||
}
|
||||
12
src/request.tests/_fixtures/DerivedScalarHandler.cs
Normal file
12
src/request.tests/_fixtures/DerivedScalarHandler.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class DerivedScalarHandler : BaseScalarHandler<DerivedScalarRequest>
|
||||
{
|
||||
public override Task<string> HandleAsync(DerivedScalarRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult($"Derived: {request.Value}");
|
||||
}
|
||||
}
|
||||
9
src/request.tests/_fixtures/DerivedScalarRequest.cs
Normal file
9
src/request.tests/_fixtures/DerivedScalarRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class DerivedScalarRequest : IScalarRequest<string>
|
||||
{
|
||||
public int Value { get; set; }
|
||||
}
|
||||
13
src/request.tests/_fixtures/DerivedStreamHandler.cs
Normal file
13
src/request.tests/_fixtures/DerivedStreamHandler.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class DerivedStreamHandler : BaseStreamHandler<DerivedStreamRequest>
|
||||
{
|
||||
public override async IAsyncEnumerable<string> HandleAsync(DerivedStreamRequest request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
yield return $"Derived: {request.Value}-0";
|
||||
yield return $"Derived: {request.Value}-1";
|
||||
}
|
||||
}
|
||||
9
src/request.tests/_fixtures/DerivedStreamRequest.cs
Normal file
9
src/request.tests/_fixtures/DerivedStreamRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class DerivedStreamRequest : IStreamRequest<string>
|
||||
{
|
||||
public int Value { get; set; }
|
||||
}
|
||||
12
src/request.tests/_fixtures/ExplicitGenericScalarHandler.cs
Normal file
12
src/request.tests/_fixtures/ExplicitGenericScalarHandler.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ExplicitGenericScalarHandler<T> : IScalarRequestHandler<ExplicitGenericScalarRequest, string>
|
||||
{
|
||||
Task<string> IScalarRequestHandler<ExplicitGenericScalarRequest, string>.HandleAsync(ExplicitGenericScalarRequest request, CancellationToken ct)
|
||||
{
|
||||
return Task.FromResult($"{request.Value}-ExplicitHandled");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ExplicitGenericScalarRequest : IScalarRequest<string>
|
||||
{
|
||||
public string Value { get; set; } = string.Empty;
|
||||
}
|
||||
12
src/request.tests/_fixtures/ExplicitGenericStreamHandler.cs
Normal file
12
src/request.tests/_fixtures/ExplicitGenericStreamHandler.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ExplicitGenericStreamHandler<T> : IStreamRequestHandler<ExplicitGenericStreamRequest, string>
|
||||
{
|
||||
async IAsyncEnumerable<string> IStreamRequestHandler<ExplicitGenericStreamRequest, string>.HandleAsync(ExplicitGenericStreamRequest request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct)
|
||||
{
|
||||
yield return $"{request.Value}-ExplicitHandled";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ExplicitGenericStreamRequest : IStreamRequest<string>
|
||||
{
|
||||
public string Value { get; set; } = string.Empty;
|
||||
}
|
||||
12
src/request.tests/_fixtures/FailingScalarHandler.cs
Normal file
12
src/request.tests/_fixtures/FailingScalarHandler.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class FailingScalarHandler : IScalarRequestHandler<FailingScalarRequest, string>
|
||||
{
|
||||
public Task<string> HandleAsync(FailingScalarRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new InvalidOperationException("Handler failed");
|
||||
}
|
||||
}
|
||||
8
src/request.tests/_fixtures/FailingScalarRequest.cs
Normal file
8
src/request.tests/_fixtures/FailingScalarRequest.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class FailingScalarRequest : IScalarRequest<string>
|
||||
{
|
||||
}
|
||||
13
src/request.tests/_fixtures/FailingStreamHandler.cs
Normal file
13
src/request.tests/_fixtures/FailingStreamHandler.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class FailingStreamHandler : IStreamRequestHandler<FailingStreamRequest, string>
|
||||
{
|
||||
public async IAsyncEnumerable<string> HandleAsync(FailingStreamRequest request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
yield return "Wait for it...";
|
||||
throw new InvalidOperationException("Handler failed");
|
||||
}
|
||||
}
|
||||
8
src/request.tests/_fixtures/FailingStreamRequest.cs
Normal file
8
src/request.tests/_fixtures/FailingStreamRequest.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class FailingStreamRequest : IStreamRequest<string>
|
||||
{
|
||||
}
|
||||
9
src/request.tests/_fixtures/INamedScalarRequest.cs
Normal file
9
src/request.tests/_fixtures/INamedScalarRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public interface INamedScalarRequest : IScalarRequest<string>
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
9
src/request.tests/_fixtures/INamedStreamRequest.cs
Normal file
9
src/request.tests/_fixtures/INamedStreamRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public interface INamedStreamRequest : IStreamRequest<string>
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
8
src/request.tests/_fixtures/InheritedScalarRequest.cs
Normal file
8
src/request.tests/_fixtures/InheritedScalarRequest.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class InheritedScalarRequest : OpenScalarRequest
|
||||
{
|
||||
}
|
||||
8
src/request.tests/_fixtures/InheritedStreamRequest.cs
Normal file
8
src/request.tests/_fixtures/InheritedStreamRequest.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class InheritedStreamRequest : OpenStreamRequest
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class InterfaceConstrainedScalarHandler<TRequest> : IScalarRequestHandler<TRequest, string>
|
||||
where TRequest : INamedScalarRequest
|
||||
{
|
||||
public Task<string> HandleAsync(TRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult($"{request.Name}-ConstrainedByInterface");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class InterfaceConstrainedStreamHandler<TRequest> : IStreamRequestHandler<TRequest, string>
|
||||
where TRequest : INamedStreamRequest
|
||||
{
|
||||
public async IAsyncEnumerable<string> HandleAsync(TRequest request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
yield return $"{request.Name}-ConstrainedByInterface-0";
|
||||
yield return $"{request.Name}-ConstrainedByInterface-1";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class InterfaceInheritedScalarHandler : IScalarRequestHandler<InterfaceInheritedScalarRequest, string>
|
||||
{
|
||||
public Task<string> HandleAsync(InterfaceInheritedScalarRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult($"{request.Name}-InterfaceHandled");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class InterfaceInheritedScalarRequest : INamedScalarRequest
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class InterfaceInheritedStreamHandler : IStreamRequestHandler<InterfaceInheritedStreamRequest, string>
|
||||
{
|
||||
public async IAsyncEnumerable<string> HandleAsync(InterfaceInheritedStreamRequest request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
yield return $"{request.Name}-InterfaceHandled-0";
|
||||
yield return $"{request.Name}-InterfaceHandled-1";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class InterfaceInheritedStreamRequest : INamedStreamRequest
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
17
src/request.tests/_fixtures/MultiInterfaceScalarHandler.cs
Normal file
17
src/request.tests/_fixtures/MultiInterfaceScalarHandler.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class MultiInterfaceScalarHandler : IScalarRequestHandler<MultiInterfaceScalarRequest, int>, IScalarRequestHandler<MultiInterfaceScalarRequest, string>
|
||||
{
|
||||
public Task<int> HandleAsync(MultiInterfaceScalarRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(1);
|
||||
}
|
||||
|
||||
Task<string> IScalarRequestHandler<MultiInterfaceScalarRequest, string>.HandleAsync(MultiInterfaceScalarRequest request, CancellationToken ct)
|
||||
{
|
||||
return Task.FromResult("One");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class MultiInterfaceScalarRequest : IScalarRequest<int>, IScalarRequest<string>
|
||||
{
|
||||
}
|
||||
19
src/request.tests/_fixtures/MultiInterfaceStreamHandler.cs
Normal file
19
src/request.tests/_fixtures/MultiInterfaceStreamHandler.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class MultiInterfaceStreamHandler : IStreamRequestHandler<MultiInterfaceStreamRequest, int>, IStreamRequestHandler<MultiInterfaceStreamRequest, string>
|
||||
{
|
||||
public async IAsyncEnumerable<int> HandleAsync(MultiInterfaceStreamRequest request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
yield return 1;
|
||||
yield return 2;
|
||||
}
|
||||
|
||||
async IAsyncEnumerable<string> IStreamRequestHandler<MultiInterfaceStreamRequest, string>.HandleAsync(MultiInterfaceStreamRequest request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct)
|
||||
{
|
||||
yield return "One";
|
||||
yield return "Two";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class MultiInterfaceStreamRequest : IStreamRequest<int>, IStreamRequest<string>
|
||||
{
|
||||
}
|
||||
13
src/request.tests/_fixtures/OpenScalarHandler.cs
Normal file
13
src/request.tests/_fixtures/OpenScalarHandler.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class OpenScalarHandler<TRequest> : IScalarRequestHandler<TRequest, string>
|
||||
where TRequest : OpenScalarRequest
|
||||
{
|
||||
public Task<string> HandleAsync(TRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult($"{request.Data}-Handled");
|
||||
}
|
||||
}
|
||||
9
src/request.tests/_fixtures/OpenScalarRequest.cs
Normal file
9
src/request.tests/_fixtures/OpenScalarRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class OpenScalarRequest : IScalarRequest<string>
|
||||
{
|
||||
public string Data { get; set; } = string.Empty;
|
||||
}
|
||||
14
src/request.tests/_fixtures/OpenStreamHandler.cs
Normal file
14
src/request.tests/_fixtures/OpenStreamHandler.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class OpenStreamHandler<TRequest> : IStreamRequestHandler<TRequest, string>
|
||||
where TRequest : OpenStreamRequest
|
||||
{
|
||||
public async IAsyncEnumerable<string> HandleAsync(TRequest request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
yield return $"{request.Data}-Stream-0";
|
||||
yield return $"{request.Data}-Stream-1";
|
||||
}
|
||||
}
|
||||
9
src/request.tests/_fixtures/OpenStreamRequest.cs
Normal file
9
src/request.tests/_fixtures/OpenStreamRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class OpenStreamRequest : IStreamRequest<string>
|
||||
{
|
||||
public string Data { get; set; } = string.Empty;
|
||||
}
|
||||
13
src/request.tests/_fixtures/ScalarChainedBehaviour1.cs
Normal file
13
src/request.tests/_fixtures/ScalarChainedBehaviour1.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ScalarChainedBehaviour1(ScalarTestTracker tracker) : IScalarRequestBehavior<ScalarTestRequest, string>
|
||||
{
|
||||
public async Task<string> HandleAsync(ScalarTestRequest request, ScalarHandlerDelegate<string> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Log.Add("Behaviour1");
|
||||
return await next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
13
src/request.tests/_fixtures/ScalarChainedBehaviour2.cs
Normal file
13
src/request.tests/_fixtures/ScalarChainedBehaviour2.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ScalarChainedBehaviour2(ScalarTestTracker tracker) : IScalarRequestBehavior<ScalarTestRequest, string>
|
||||
{
|
||||
public async Task<string> HandleAsync(ScalarTestRequest request, ScalarHandlerDelegate<string> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Log.Add("Behaviour2");
|
||||
return await next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
14
src/request.tests/_fixtures/ScalarOpenBehavior.cs
Normal file
14
src/request.tests/_fixtures/ScalarOpenBehavior.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ScalarOpenBehavior<TRequest, TResponse>(ScalarTestTracker tracker) : IScalarRequestBehavior<TRequest, TResponse>
|
||||
where TRequest : IScalarRequest<TResponse>
|
||||
{
|
||||
public async Task<TResponse> HandleAsync(TRequest request, ScalarHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Executed = true;
|
||||
return await next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
13
src/request.tests/_fixtures/ScalarOrderingClosedBehavior.cs
Normal file
13
src/request.tests/_fixtures/ScalarOrderingClosedBehavior.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ScalarOrderingClosedBehavior(ScalarTestTracker tracker) : IScalarRequestBehavior<ScalarTestRequest, string>
|
||||
{
|
||||
public Task<string> HandleAsync(ScalarTestRequest request, ScalarHandlerDelegate<string> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Log.Add("OrderingClosed");
|
||||
return next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
14
src/request.tests/_fixtures/ScalarOrderingOpenBehavior.cs
Normal file
14
src/request.tests/_fixtures/ScalarOrderingOpenBehavior.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ScalarOrderingOpenBehavior<TRequest, TOutput>(ScalarTestTracker tracker) : IScalarRequestBehavior<TRequest, TOutput>
|
||||
where TRequest : IScalarRequest<TOutput>
|
||||
{
|
||||
public Task<TOutput> HandleAsync(TRequest request, ScalarHandlerDelegate<TOutput> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Log.Add("OrderingOpen");
|
||||
return next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
13
src/request.tests/_fixtures/ScalarTestBehavior.cs
Normal file
13
src/request.tests/_fixtures/ScalarTestBehavior.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ScalarTestBehavior(ScalarTestTracker tracker) : IScalarRequestBehavior<ScalarTestRequest, string>
|
||||
{
|
||||
public async Task<string> HandleAsync(ScalarTestRequest request, ScalarHandlerDelegate<string> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Executed = true;
|
||||
return await next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
12
src/request.tests/_fixtures/ScalarTestHandler.cs
Normal file
12
src/request.tests/_fixtures/ScalarTestHandler.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ScalarTestHandler : IScalarRequestHandler<ScalarTestRequest, string>
|
||||
{
|
||||
public Task<string> HandleAsync(ScalarTestRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult($"{request.Value}-Handled");
|
||||
}
|
||||
}
|
||||
9
src/request.tests/_fixtures/ScalarTestRequest.cs
Normal file
9
src/request.tests/_fixtures/ScalarTestRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ScalarTestRequest : IScalarRequest<string>
|
||||
{
|
||||
public string Value { get; set; } = string.Empty;
|
||||
}
|
||||
10
src/request.tests/_fixtures/ScalarTestTracker.cs
Normal file
10
src/request.tests/_fixtures/ScalarTestTracker.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ScalarTestTracker
|
||||
{
|
||||
public List<string> Log { get; } = [];
|
||||
public bool Executed { get; set; }
|
||||
}
|
||||
12
src/request.tests/_fixtures/ScalarTestWrapperHandler.cs
Normal file
12
src/request.tests/_fixtures/ScalarTestWrapperHandler.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ScalarTestWrapperHandler<T> : IScalarRequestHandler<ScalarTestWrapperRequest<T>, string>
|
||||
{
|
||||
public Task<string> HandleAsync(ScalarTestWrapperRequest<T> request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult($"Handled-{request.Item}");
|
||||
}
|
||||
}
|
||||
9
src/request.tests/_fixtures/ScalarTestWrapperRequest.cs
Normal file
9
src/request.tests/_fixtures/ScalarTestWrapperRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ScalarTestWrapperRequest<T> : IScalarRequest<string>
|
||||
{
|
||||
public T Item { get; set; } = default!;
|
||||
}
|
||||
13
src/request.tests/_fixtures/ScalarWrapperBehavior.cs
Normal file
13
src/request.tests/_fixtures/ScalarWrapperBehavior.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class ScalarWrapperBehavior<T>(ScalarTestTracker tracker) : IScalarRequestBehavior<ScalarTestWrapperRequest<T>, string>
|
||||
{
|
||||
public async Task<string> HandleAsync(ScalarTestWrapperRequest<T> request, ScalarHandlerDelegate<string> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Executed = true;
|
||||
return await next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
13
src/request.tests/_fixtures/StreamChainedBehaviour1.cs
Normal file
13
src/request.tests/_fixtures/StreamChainedBehaviour1.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class StreamChainedBehaviour1(StreamTestTracker tracker) : IStreamRequestBehavior<StreamTestRequest, string>
|
||||
{
|
||||
public IAsyncEnumerable<string> HandleAsync(StreamTestRequest request, StreamHandlerDelegate<string> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Log.Add("Behaviour1");
|
||||
return next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
13
src/request.tests/_fixtures/StreamChainedBehaviour2.cs
Normal file
13
src/request.tests/_fixtures/StreamChainedBehaviour2.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class StreamChainedBehaviour2(StreamTestTracker tracker) : IStreamRequestBehavior<StreamTestRequest, string>
|
||||
{
|
||||
public IAsyncEnumerable<string> HandleAsync(StreamTestRequest request, StreamHandlerDelegate<string> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Log.Add("Behaviour2");
|
||||
return next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
14
src/request.tests/_fixtures/StreamOpenBehavior.cs
Normal file
14
src/request.tests/_fixtures/StreamOpenBehavior.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class StreamOpenBehavior<TRequest, TResponse>(StreamTestTracker tracker) : IStreamRequestBehavior<TRequest, TResponse>
|
||||
where TRequest : IStreamRequest<TResponse>
|
||||
{
|
||||
public IAsyncEnumerable<TResponse> HandleAsync(TRequest request, StreamHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Executed = true;
|
||||
return next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
13
src/request.tests/_fixtures/StreamOrderingClosedBehavior.cs
Normal file
13
src/request.tests/_fixtures/StreamOrderingClosedBehavior.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class StreamOrderingClosedBehavior(StreamTestTracker tracker) : IStreamRequestBehavior<StreamTestRequest, string>
|
||||
{
|
||||
public IAsyncEnumerable<string> HandleAsync(StreamTestRequest request, StreamHandlerDelegate<string> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Log.Add("Closed");
|
||||
return next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
14
src/request.tests/_fixtures/StreamOrderingOpenBehavior.cs
Normal file
14
src/request.tests/_fixtures/StreamOrderingOpenBehavior.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class StreamOrderingOpenBehavior<TRequest, TOutput>(StreamTestTracker tracker) : IStreamRequestBehavior<TRequest, TOutput>
|
||||
where TRequest : IStreamRequest<TOutput>
|
||||
{
|
||||
public IAsyncEnumerable<TOutput> HandleAsync(TRequest request, StreamHandlerDelegate<TOutput> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Log.Add("Open");
|
||||
return next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
13
src/request.tests/_fixtures/StreamTestBehavior.cs
Normal file
13
src/request.tests/_fixtures/StreamTestBehavior.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class StreamTestBehavior(StreamTestTracker tracker) : IStreamRequestBehavior<StreamTestRequest, string>
|
||||
{
|
||||
public IAsyncEnumerable<string> HandleAsync(StreamTestRequest request, StreamHandlerDelegate<string> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Executed = true;
|
||||
return next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
13
src/request.tests/_fixtures/StreamTestHandler.cs
Normal file
13
src/request.tests/_fixtures/StreamTestHandler.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class StreamTestHandler : IStreamRequestHandler<StreamTestRequest, string>
|
||||
{
|
||||
public async IAsyncEnumerable<string> HandleAsync(StreamTestRequest request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
yield return $"{request.Value}-Handled-0";
|
||||
yield return $"{request.Value}-Handled-1";
|
||||
}
|
||||
}
|
||||
9
src/request.tests/_fixtures/StreamTestRequest.cs
Normal file
9
src/request.tests/_fixtures/StreamTestRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class StreamTestRequest : IStreamRequest<string>
|
||||
{
|
||||
public string Value { get; set; } = string.Empty;
|
||||
}
|
||||
10
src/request.tests/_fixtures/StreamTestTracker.cs
Normal file
10
src/request.tests/_fixtures/StreamTestTracker.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class StreamTestTracker
|
||||
{
|
||||
public List<string> Log { get; } = [];
|
||||
public bool Executed { get; set; }
|
||||
}
|
||||
13
src/request.tests/_fixtures/StreamTestWrapperHandler.cs
Normal file
13
src/request.tests/_fixtures/StreamTestWrapperHandler.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class StreamTestWrapperHandler<T> : IStreamRequestHandler<StreamTestWrapperRequest<T>, string>
|
||||
{
|
||||
public async IAsyncEnumerable<string> HandleAsync(StreamTestWrapperRequest<T> request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
yield return $"Handled-{request.Item}-0";
|
||||
yield return $"Handled-{request.Item}-1";
|
||||
}
|
||||
}
|
||||
9
src/request.tests/_fixtures/StreamTestWrapperRequest.cs
Normal file
9
src/request.tests/_fixtures/StreamTestWrapperRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class StreamTestWrapperRequest<T> : IStreamRequest<string>
|
||||
{
|
||||
public T? Item { get; set; }
|
||||
}
|
||||
13
src/request.tests/_fixtures/StreamWrapperBehavior.cs
Normal file
13
src/request.tests/_fixtures/StreamWrapperBehavior.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class StreamWrapperBehavior<T>(StreamTestTracker tracker) : IStreamRequestBehavior<StreamTestWrapperRequest<T>, string>
|
||||
{
|
||||
public IAsyncEnumerable<string> HandleAsync(StreamTestWrapperRequest<T> request, StreamHandlerDelegate<string> next, CancellationToken cancellationToken)
|
||||
{
|
||||
tracker.Executed = true;
|
||||
return next(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
12
src/request.tests/_fixtures/TestHandler.cs
Normal file
12
src/request.tests/_fixtures/TestHandler.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
internal sealed class TestHandler : IScalarRequestHandler<TestRequest, string>
|
||||
{
|
||||
public Task<string> HandleAsync(TestRequest request, CancellationToken ct)
|
||||
{
|
||||
return Task.FromResult("ok");
|
||||
}
|
||||
}
|
||||
6
src/request.tests/_fixtures/TestRequest.cs
Normal file
6
src/request.tests/_fixtures/TestRequest.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
internal sealed class TestRequest : IScalarRequest<string> { }
|
||||
8
src/request.tests/_fixtures/UnhandledScalarRequest.cs
Normal file
8
src/request.tests/_fixtures/UnhandledScalarRequest.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class UnhandledScalarRequest : IScalarRequest<string>
|
||||
{
|
||||
}
|
||||
8
src/request.tests/_fixtures/UnhandledStreamRequest.cs
Normal file
8
src/request.tests/_fixtures/UnhandledStreamRequest.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class UnhandledStreamRequest : IStreamRequest<string>
|
||||
{
|
||||
}
|
||||
12
src/request.tests/_fixtures/WrapperScalarHandler.cs
Normal file
12
src/request.tests/_fixtures/WrapperScalarHandler.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class WrapperScalarHandler<T> : IScalarRequestHandler<WrapperScalarRequest<T>, string>
|
||||
{
|
||||
public Task<string> HandleAsync(WrapperScalarRequest<T> request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult($"Handled-{request.Item}");
|
||||
}
|
||||
}
|
||||
9
src/request.tests/_fixtures/WrapperScalarRequest.cs
Normal file
9
src/request.tests/_fixtures/WrapperScalarRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class WrapperScalarRequest<T> : IScalarRequest<string>
|
||||
{
|
||||
public T Item { get; set; } = default!;
|
||||
}
|
||||
13
src/request.tests/_fixtures/WrapperStreamHandler.cs
Normal file
13
src/request.tests/_fixtures/WrapperStreamHandler.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class WrapperStreamHandler<T> : IStreamRequestHandler<WrapperStreamRequest<T>, string>
|
||||
{
|
||||
public async IAsyncEnumerable<string> HandleAsync(WrapperStreamRequest<T> request, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
yield return $"Handled-{request.Item}-0";
|
||||
yield return $"Handled-{request.Item}-1";
|
||||
}
|
||||
}
|
||||
9
src/request.tests/_fixtures/WrapperStreamRequest.cs
Normal file
9
src/request.tests/_fixtures/WrapperStreamRequest.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
namespace Geekeey.Request.Tests;
|
||||
|
||||
public class WrapperStreamRequest<T> : IStreamRequest<string>
|
||||
{
|
||||
public T Item { get; set; } = default!;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue