-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
Fix/event constraint append many
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) Cratis. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Cratis.Chronicle.Concepts.Events; | ||
using Cratis.Chronicle.EventSequences; | ||
using Cratis.Chronicle.Integration.Base; | ||
using context = Cratis.Chronicle.Integration.Orleans.InProcess.for_EventSequence.when_appending.many_with_first_event_violating_unique_constraint.context; | ||
|
||
namespace Cratis.Chronicle.Integration.Orleans.InProcess.for_EventSequence.when_appending; | ||
|
||
[Collection(GlobalCollection.Name)] | ||
public class many_with_first_event_violating_unique_constraint(context context) : Given<context>(context) | ||
{ | ||
public class context(GlobalFixture globalFixture) : IntegrationSpecificationContext(globalFixture) | ||
{ | ||
public override IEnumerable<Type> ConstraintTypes => [typeof(UniqueUserConstraint)]; | ||
public override IEnumerable<Type> EventTypes => [typeof(UserOnboardingStarted), typeof(UserRemoved)]; | ||
|
||
public UserOnboardingStarted Event { get; private set; } | ||
|
||
public AppendManyResult Result { get; private set; } | ||
|
||
public async Task Establish() | ||
{ | ||
Event = new UserOnboardingStarted(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); | ||
await EventStore.EventLog.Append(Guid.NewGuid().ToString(), Event); | ||
} | ||
|
||
public async Task Because() | ||
{ | ||
Result = await EventStore.EventLog.AppendMany(Guid.NewGuid().ToString(), [Event, new UserRemoved()]); | ||
} | ||
} | ||
|
||
[Fact] void should_not_succeed_on_second_attempt() => Context.Result.IsSuccess.ShouldBeFalse(); | ||
[Fact] void should_not_commit_any_of_the_two_events() => Context.EventLogSequenceGrain.GetTailSequenceNumber().Result.Value.ShouldEqual(EventSequenceNumber.First.Value); | ||
Check warning on line 36 in Integration/Orleans.InProcess/for_EventSequence/when_appending/many_with_first_event_violating_unique_constraint.cs
|
||
} | ||
|