Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LiquidProjections.Abstractions" Version="2.2.0" />
<PackageReference Include="LiquidProjections.Abstractions" Version="2.3.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="System.Dynamic.Runtime" Version="4.3.0" />
</ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions Src/LiquidProjections.PollingEventStore/Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ public void Start()
LogProvider.GetLogger(typeof(Subscription)).Debug(() => $"Subscription {Id} has been started.");
#endif

SubscriptionInfo info = new SubscriptionInfo
var info = new SubscriptionInfo
{
Id = Id,
Subscription = this
Subscription = this,
CancellationToken = cancellationTokenSource.Token
};

Task = Task.Factory.StartNew(async () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<Reference Include="FluentAssertions.Core, Version=4.19.3.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\..\packages\FluentAssertions.4.19.3\lib\net45\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="LiquidProjections.Abstractions, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\LiquidProjections.Abstractions.2.2.0\lib\netstandard1.1\LiquidProjections.Abstractions.dll</HintPath>
<Reference Include="LiquidProjections.Abstractions, Version=2.3.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\packages\LiquidProjections.Abstractions.2.3.0\lib\netstandard1.1\LiquidProjections.Abstractions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,5 +461,63 @@ public void Then_it_should_cancel_the_subscription_asynchronously()
}
}
}

public class When_the_transaction_handler_has_delay_which_uses_the_cancellation_token_and_the_subscription_is_cancelled :
GivenSubject<PollingEventStoreAdapter>
{
private readonly TimeSpan pollingInterval = 500.Milliseconds();
private readonly DateTime utcNow = DateTime.UtcNow;
private readonly ManualResetEventSlim transactionHandlerStarted = new ManualResetEventSlim();
private readonly ManualResetEventSlim transactionHandlerCancelled = new ManualResetEventSlim();
private IDisposable subscription;

public When_the_transaction_handler_has_delay_which_uses_the_cancellation_token_and_the_subscription_is_cancelled()
{
Given(() =>
{
UseThe(new TransactionBuilder().WithCheckpoint(123).Build());

UseThe(A.Fake<IPassiveEventStore>());
A.CallTo(() => The<IPassiveEventStore>().GetFrom(A<long?>.Ignored)).Returns(new[] { The<Transaction>() });

WithSubject(_ => new PollingEventStoreAdapter(The<IPassiveEventStore>(), 11, pollingInterval, 100,
() => utcNow));

subscription = Subject.Subscribe(null,
new Subscriber
{
HandleTransactions = async (transactions, info) =>
{
transactionHandlerStarted.Set();

try
{
await Task.Delay(TimeSpan.FromDays(1), info.CancellationToken.Value);
}
catch (OperationCanceledException)
{
transactionHandlerCancelled.Set();
}
}
},
"someId");
});

When(() =>
{
transactionHandlerStarted.Wait();
subscription.Dispose();
});
}

[Fact]
public void Then_it_should_cancel_the_transaction_handler()
{
if (!transactionHandlerCancelled.Wait(TimeSpan.FromSeconds(10)))
{
throw new InvalidOperationException("The transaction handler was not cancelled in 10 seconds.");
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package id="Chill" version="3.0.1" targetFramework="net452" />
<package id="FakeItEasy" version="3.4.2" targetFramework="net452" />
<package id="FluentAssertions" version="4.19.3" targetFramework="net452" />
<package id="LiquidProjections.Abstractions" version="2.2.0" targetFramework="net452" />
<package id="LiquidProjections.Abstractions" version="2.3.0" targetFramework="net452" />
<package id="xunit" version="2.2.0" targetFramework="net452" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="net452" />
<package id="xunit.assert" version="2.2.0" targetFramework="net452" />
Expand Down