Skip to content

Add the ability to mock TransactWrite and MultiTableTransactWrite operations #3436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2024
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
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