Skip to content

Commit

Permalink
Add the ability to mock TransactWrite and MultiTableTransactWrite ope…
Browse files Browse the repository at this point in the history
…rations
  • Loading branch information
96malhar committed Aug 13, 2024
1 parent 08307bc commit 8922aff
Show file tree
Hide file tree
Showing 10 changed files with 380 additions and 293 deletions.
38 changes: 8 additions & 30 deletions sdk/src/Services/DynamoDBv2/Custom/DataModel/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,52 +342,30 @@ public MultiTableTransactGet CreateMultiTableTransactGet(params TransactGet[] tr

#region TransactWrite

/// <summary>
/// Creates a strongly-typed TransactWrite object, allowing
/// a transactional write operation against DynamoDB.
/// </summary>
/// <typeparam name="T">Type of objects to write.</typeparam>
/// <returns>Empty strongly-typed TransactWrite object.</returns>
public TransactWrite<T> CreateTransactWrite<T>()
/// <inheritdoc/>
public ITransactWrite<T> CreateTransactWrite<T>()
{
return CreateTransactWrite<T>((TransactWriteConfig)null);
}

/// <summary>
/// Creates a strongly-typed TransactWrite object, allowing
/// a transactional write operation against DynamoDB.
/// </summary>
/// <typeparam name="T">Type of objects to write.</typeparam>
/// <param name="operationConfig">Config object which can be used to override that table used.</param>
/// <returns>Empty strongly-typed TransactWrite object.</returns>
/// <inheritdoc/>

[Obsolete("Use the CreateTransactWrite overload that takes TransactWriteConfig instead, since DynamoDBOperationConfig contains properties that are not applicable to CreateTransactWrite.")]
public TransactWrite<T> CreateTransactWrite<T>(DynamoDBOperationConfig operationConfig)
public ITransactWrite<T> CreateTransactWrite<T>(DynamoDBOperationConfig operationConfig)
{
DynamoDBFlatConfig config = new DynamoDBFlatConfig(operationConfig, this.Config);
return new TransactWrite<T>(this, config);
}

/// <summary>
/// Creates a strongly-typed TransactWrite object, allowing
/// a transactional write operation against DynamoDB.
/// </summary>
/// <typeparam name="T">Type of objects to write.</typeparam>
/// <param name="transactWriteConfig">Config object that can be used to override properties on the table's context for this request.</param>
/// <returns>Empty strongly-typed TransactWrite object.</returns>
public TransactWrite<T> CreateTransactWrite<T>(TransactWriteConfig transactWriteConfig)
/// <inheritdoc/>
public ITransactWrite<T> CreateTransactWrite<T>(TransactWriteConfig transactWriteConfig)
{
DynamoDBFlatConfig config = new DynamoDBFlatConfig(transactWriteConfig?.ToDynamoDBOperationConfig(), this.Config);
return new TransactWrite<T>(this, config);
}

/// <summary>
/// Creates a MultiTableTransactWrite object, composed of multiple
/// individual TransactWrite objects.
/// </summary>
/// <param name="transactionParts">Individual TransactWrite objects.</param>
/// <returns>Composite MultiTableTransactWrite object.</returns>
public MultiTableTransactWrite CreateMultiTableTransactWrite(params TransactWrite[] transactionParts)
/// <inheritdoc/>
public IMultiTableTransactWrite CreateMultiTableTransactWrite(params ITransactWrite[] transactionParts)
{
return new MultiTableTransactWrite(transactionParts);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public partial interface IDynamoDBContext : IDisposable
/// </summary>
/// <typeparam name="T">Type of objects to write.</typeparam>
/// <returns>Empty strongly-typed TransactWrite object.</returns>
TransactWrite<T> CreateTransactWrite<T>();
ITransactWrite<T> CreateTransactWrite<T>();

/// <summary>
/// Creates a strongly-typed TransactWrite object, allowing
Expand All @@ -326,7 +326,7 @@ public partial interface IDynamoDBContext : IDisposable
/// <param name="operationConfig">Config object which can be used to override that table used.</param>
/// <returns>Empty strongly-typed TransactWrite object.</returns>
[Obsolete("Use the CreateTransactWrite overload that takes TransactWriteConfig instead, since DynamoDBOperationConfig contains properties that are not applicable to CreateTransactWrite.")]
TransactWrite<T> CreateTransactWrite<T>(DynamoDBOperationConfig operationConfig = null);
ITransactWrite<T> CreateTransactWrite<T>(DynamoDBOperationConfig operationConfig = null);

/// <summary>
/// Creates a strongly-typed TransactWrite object, allowing
Expand All @@ -335,15 +335,15 @@ public partial interface IDynamoDBContext : IDisposable
/// <typeparam name="T">Type of objects to write.</typeparam>
/// <param name="transactWriteConfig">Config object that can be used to override properties on the table's context for this request.</param>
/// <returns>Empty strongly-typed TransactWrite object.</returns>
TransactWrite<T> CreateTransactWrite<T>(TransactWriteConfig transactWriteConfig);
ITransactWrite<T> CreateTransactWrite<T>(TransactWriteConfig transactWriteConfig);

/// <summary>
/// Creates a MultiTableTransactWrite object, composed of multiple
/// individual TransactWrite objects.
/// </summary>
/// <param name="transactionParts">Individual TransactWrite objects.</param>
/// <returns>Composite MultiTableTransactWrite object.</returns>
MultiTableTransactWrite CreateMultiTableTransactWrite(params TransactWrite[] transactionParts);
IMultiTableTransactWrite CreateMultiTableTransactWrite(params ITransactWrite[] transactionParts);

#endregion
}
Expand Down
Loading

0 comments on commit 8922aff

Please sign in to comment.