Skip to content

Commit 9a0bc80

Browse files
refactor: rename TransactionCommand to TransactionStep
less confusing
1 parent 4215e91 commit 9a0bc80

File tree

17 files changed

+85
-85
lines changed

17 files changed

+85
-85
lines changed

src/EntityDb.Abstractions/Transactions/ITransaction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public interface ITransaction<TEntity>
2929
/// A series of sets of modifiers for a set of entities.
3030
/// </summary>
3131
/// <remarks>
32-
/// <see cref="Commands" /> must be handled in the order they are given.
32+
/// <see cref="Steps" /> must be handled in the order they are given.
3333
/// </remarks>
34-
ImmutableArray<ITransactionCommand<TEntity>> Commands { get; }
34+
ImmutableArray<ITransactionStep<TEntity>> Steps { get; }
3535
}
3636
}

src/EntityDb.Abstractions/Transactions/ITransactionCommand.cs renamed to src/EntityDb.Abstractions/Transactions/ITransactionStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace EntityDb.Abstractions.Transactions
99
/// Represents a set of modifiers for a single entity.
1010
/// </summary>
1111
/// <typeparam name="TEntity">The type of entity to be modified.</typeparam>
12-
public interface ITransactionCommand<TEntity>
12+
public interface ITransactionStep<TEntity>
1313
{
1414
/// <summary>
1515
/// A snapshot of the entity before the command.

src/EntityDb.Common.Tests/Transactions/TransactionBuilderTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ public void GivenLeasingStrategy_WhenBuildingNewEntityWithLease_ThenTransactionD
181181

182182
// ASSERT
183183

184-
transaction.Commands.Length.ShouldBe(1);
184+
transaction.Steps.Length.ShouldBe(1);
185185

186-
transaction.Commands[0].Leases.Insert.ShouldNotBeEmpty();
186+
transaction.Steps[0].Leases.Insert.ShouldNotBeEmpty();
187187
}
188188

189189
[Fact]
@@ -203,9 +203,9 @@ public void GivenNoLeasingStrategy_WhenBuildingNewEntityWithLease_ThenTransactio
203203

204204
// ASSERT
205205

206-
transaction.Commands.Length.ShouldBe(1);
206+
transaction.Steps.Length.ShouldBe(1);
207207

208-
transaction.Commands[0].Leases.Insert.ShouldBeEmpty();
208+
transaction.Steps[0].Leases.Insert.ShouldBeEmpty();
209209
}
210210

211211
[Fact]
@@ -295,7 +295,7 @@ public void GivenNonExistingEntityId_WhenUsingValidVersioningStrategy_ThenVersio
295295

296296
for (ulong i = 1; i <= NumberOfVersionsToTest; i++)
297297
{
298-
transaction.Commands[(int)(i-1)].NextEntityVersionNumber.ShouldBe(i);
298+
transaction.Steps[(int)(i-1)].NextEntityVersionNumber.ShouldBe(i);
299299
}
300300
}
301301

@@ -330,9 +330,9 @@ public async Task GivenExistingEntity_WhenAppendingNewCommand_ThenTransactionBui
330330

331331
// ASSERT
332332

333-
transaction.Commands.Length.ShouldBe(1);
333+
transaction.Steps.Length.ShouldBe(1);
334334

335-
transaction.Commands[0].Command.ShouldBeEquivalentTo(new DoNothing());
335+
transaction.Steps[0].Command.ShouldBeEquivalentTo(new DoNothing());
336336
}
337337
}
338338
}

src/EntityDb.Common.Tests/Transactions/TransactionTestsBase.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,11 @@ public async Task
518518

519519
// ASSERT
520520

521-
firstTransaction.Commands.Length.ShouldBe(1);
522-
secondTransaction.Commands.Length.ShouldBe(1);
521+
firstTransaction.Steps.Length.ShouldBe(1);
522+
secondTransaction.Steps.Length.ShouldBe(1);
523523

524-
firstTransaction.Commands[0].EntityId.ShouldBe(secondTransaction.Commands[0].EntityId);
525-
firstTransaction.Commands[0].NextEntityVersionNumber.ShouldBe(secondTransaction.Commands[0].NextEntityVersionNumber);
524+
firstTransaction.Steps[0].EntityId.ShouldBe(secondTransaction.Steps[0].EntityId);
525+
firstTransaction.Steps[0].NextEntityVersionNumber.ShouldBe(secondTransaction.Steps[0].NextEntityVersionNumber);
526526

527527
firstTransactionInserted.ShouldBeTrue();
528528
secondTransactionInserted.ShouldBeFalse();
@@ -741,9 +741,9 @@ public async Task GivenTransactionCreatesEntity_WhenQueryingForVersionOne_ThenRe
741741

742742
// ASSERT
743743

744-
transaction.Commands.Length.ShouldBe(1);
744+
transaction.Steps.Length.ShouldBe(1);
745745

746-
transaction.Commands[0].NextEntityVersionNumber.ShouldBe(1ul);
746+
transaction.Steps[0].NextEntityVersionNumber.ShouldBe(1ul);
747747

748748
newCommands.Length.ShouldBe(1);
749749

@@ -784,9 +784,9 @@ public async Task
784784

785785
// ASSERT
786786

787-
secondTransaction.Commands.Length.ShouldBe(1);
787+
secondTransaction.Steps.Length.ShouldBe(1);
788788

789-
secondTransaction.Commands[0].NextEntityVersionNumber.ShouldBe(2ul);
789+
secondTransaction.Steps[0].NextEntityVersionNumber.ShouldBe(2ul);
790790

791791
newCommands.Length.ShouldBe(1);
792792

src/EntityDb.Common/Exceptions/OptimisticConcurrencyException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace EntityDb.Common.Exceptions
77
/// <summary>
88
/// The exception that is logged when an actor passes a <see cref="ITransaction{TEntity}" /> to an
99
/// <see cref="ITransactionRepository{TEntity}" /> with a
10-
/// <see cref="ITransactionCommand{TEntity}.PreviousEntityVersionNumber" /> that is not the actual
10+
/// <see cref="ITransactionStep{TEntity}.PreviousEntityVersionNumber" /> that is not the actual
1111
/// previous version number.
1212
/// </summary>
1313
/// <remarks>

src/EntityDb.Common/Exceptions/VersionZeroReservedException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace EntityDb.Common.Exceptions
66
/// <summary>
77
/// The exception that is thrown when an actor passes an <see cref="ITransaction{TEntity}" /> to
88
/// <see cref="ITransactionRepository{TEntity}.PutTransaction(ITransaction{TEntity})" /> with any
9-
/// <see cref="ITransactionCommand{TEntity}.NextEntityVersionNumber"/> equal to zero.
9+
/// <see cref="ITransactionStep{TEntity}.NextEntityVersionNumber"/> equal to zero.
1010
/// </summary>
1111
/// <remarks>
1212
/// Version Zero is reserved for an entity that has not yet been created/persisted.

src/EntityDb.Common/Transactions/SnapshottingTransactionSubscriber.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bool testMode
2424

2525
protected override async Task NotifyAsync(ITransaction<TEntity> transaction)
2626
{
27-
var commandGroups = transaction.Commands
27+
var commandGroups = transaction.Steps
2828
.GroupBy(command => command.EntityId);
2929

3030
foreach (var commandGroup in commandGroups)
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using EntityDb.Abstractions.Transactions;
2-
using System;
3-
using System.Collections.Immutable;
4-
5-
namespace EntityDb.Common.Transactions
6-
{
7-
internal sealed record Transaction<TEntity> : ITransaction<TEntity>
8-
{
9-
public Guid Id { get; init; }
10-
public DateTime TimeStamp { get; init; }
11-
public object Source { get; init; } = default!;
12-
public ImmutableArray<ITransactionCommand<TEntity>> Commands { get; init; }
13-
}
14-
}
1+
using EntityDb.Abstractions.Transactions;
2+
using System;
3+
using System.Collections.Immutable;
4+
5+
namespace EntityDb.Common.Transactions
6+
{
7+
internal sealed record Transaction<TEntity> : ITransaction<TEntity>
8+
{
9+
public Guid Id { get; init; }
10+
public DateTime TimeStamp { get; init; }
11+
public object Source { get; init; } = default!;
12+
public ImmutableArray<ITransactionStep<TEntity>> Steps { get; init; }
13+
}
14+
}

src/EntityDb.Common/Transactions/TransactionBuilder.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public sealed class TransactionBuilder<TEntity>
2727
private readonly ILeasingStrategy<TEntity>? _leasingStrategy;
2828
private readonly ITaggingStrategy<TEntity>? _taggingStrategy;
2929
private readonly Dictionary<Guid, TEntity> _knownEntities = new();
30-
private readonly List<TransactionCommand<TEntity>> _transactionCommands = new();
30+
private readonly List<TransactionStep<TEntity>> _transactionSteps = new();
3131

3232
/// <summary>
3333
/// Initializes a new instance of <see cref="TransactionBuilder{TEntity}" />.
@@ -76,7 +76,7 @@ private ITag[] GetTags(TEntity entity)
7676
return _taggingStrategy?.GetTags(entity) ?? Array.Empty<ITag>();
7777
}
7878

79-
private void AddTransactionCommand(Guid entityId, ICommand<TEntity> command)
79+
private void AddTransactionStep(Guid entityId, ICommand<TEntity> command)
8080
{
8181
var previousEntity = _knownEntities[entityId];
8282
var previousEntityVersionNumber = _versioningStrategy.GetVersionNumber(previousEntity);
@@ -86,7 +86,7 @@ private void AddTransactionCommand(Guid entityId, ICommand<TEntity> command)
8686
var nextEntity = previousEntity.Reduce(command);
8787
var nextEntityVersionNumber = _versioningStrategy.GetVersionNumber(nextEntity);
8888

89-
_transactionCommands.Add(new TransactionCommand<TEntity>
89+
_transactionSteps.Add(new TransactionStep<TEntity>
9090
{
9191
PreviousEntitySnapshot = previousEntity,
9292
PreviousEntityVersionNumber = previousEntityVersionNumber,
@@ -148,7 +148,7 @@ public TransactionBuilder<TEntity> Create(Guid entityId, ICommand<TEntity> comma
148148

149149
_knownEntities.Add(entityId, entity);
150150

151-
AddTransactionCommand(entityId, command);
151+
AddTransactionStep(entityId, command);
152152

153153
return this;
154154
}
@@ -166,7 +166,7 @@ public TransactionBuilder<TEntity> Append(Guid entityId, ICommand<TEntity> comma
166166
throw new EntityNotLoadedException();
167167
}
168168

169-
AddTransactionCommand(entityId, command);
169+
AddTransactionStep(entityId, command);
170170

171171
return this;
172172
}
@@ -195,10 +195,10 @@ public ITransaction<TEntity> Build(Guid transactionId, object source, DateTime?
195195
Id = transactionId,
196196
TimeStamp = timeStamp,
197197
Source = source,
198-
Commands = _transactionCommands.ToImmutableArray<ITransactionCommand<TEntity>>()
198+
Steps = _transactionSteps.ToImmutableArray<ITransactionStep<TEntity>>()
199199
};
200200

201-
_transactionCommands.Clear();
201+
_transactionSteps.Clear();
202202

203203
return transaction;
204204
}

src/EntityDb.Common/Transactions/TransactionCommand.cs renamed to src/EntityDb.Common/Transactions/TransactionStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace EntityDb.Common.Transactions
88
{
9-
internal sealed record TransactionCommand<TEntity> : ITransactionCommand<TEntity>
9+
internal sealed record TransactionStep<TEntity> : ITransactionStep<TEntity>
1010
{
1111
public TEntity PreviousEntitySnapshot { get; init; } = default!;
1212
public ulong PreviousEntityVersionNumber { get; init; }

0 commit comments

Comments
 (0)