Skip to content

Commit

Permalink
Add the ability to mock TransactGet and MultiTableTransactGet operations
Browse files Browse the repository at this point in the history
  • Loading branch information
96malhar committed Aug 8, 2024
1 parent 96b5be0 commit 9e67016
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 241 deletions.
2 changes: 1 addition & 1 deletion sdk/src/Core/AWSSDK.Core.NetFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@
<ItemGroup>
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion sdk/src/Core/AWSSDK.Core.NetStandard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>
</Project>
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 @@ -346,51 +346,29 @@ public MultiTableBatchWrite CreateMultiTableBatchWrite(params BatchWrite[] batch

#region TransactGet

/// <summary>
/// Creates a strongly-typed TransactGet object, allowing
/// a transactional get operation against DynamoDB.
/// </summary>
/// <typeparam name="T">Type of objects to get.</typeparam>
/// <returns>Empty strongly-typed TransactGet object.</returns>
public TransactGet<T> CreateTransactGet<T>()
/// <inheritdoc/>
public ITransactGet<T> CreateTransactGet<T>()
{
return CreateTransactGet<T>((TransactGetConfig)null);
}

/// <summary>
/// Creates a strongly-typed TransactGet object, allowing
/// a transactional get operation against DynamoDB.
/// </summary>
/// <typeparam name="T">Type of objects to get.</typeparam>
/// <param name="operationConfig">Config object which can be used to override that table used.</param>
/// <returns>Empty strongly-typed TransactGet object.</returns>
/// <inheritdoc/>
[Obsolete("Use the CreateTransactGet overload that takes TransactGetConfig instead, since DynamoDBOperationConfig contains properties that are not applicable to BatchGet.")]
public TransactGet<T> CreateTransactGet<T>(DynamoDBOperationConfig operationConfig)
public ITransactGet<T> CreateTransactGet<T>(DynamoDBOperationConfig operationConfig)
{
DynamoDBFlatConfig config = new DynamoDBFlatConfig(operationConfig, this.Config);
return new TransactGet<T>(this, config);
}

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

/// <summary>
/// Creates a MultiTableTransactGet object, composed of multiple
/// individual TransactGet objects.
/// </summary>
/// <param name="transactionParts">Individual TransactGet objects.</param>
/// <returns>Composite MultiTableTransactGet object.</returns>
public MultiTableTransactGet CreateMultiTableTransactGet(params TransactGet[] transactionParts)
/// <inheritdoc/>
public IMultiTableTransactGet CreateMultiTableTransactGet(params ITransactGet[] transactionParts)
{
return new MultiTableTransactGet(transactionParts);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public partial interface IDynamoDBContext : IDisposable
/// </summary>
/// <typeparam name="T">Type of objects to get.</typeparam>
/// <returns>Empty strongly-typed TransactGet object.</returns>
TransactGet<T> CreateTransactGet<T>();
ITransactGet<T> CreateTransactGet<T>();

/// <summary>
/// Creates a strongly-typed TransactGet object, allowing
Expand All @@ -287,7 +287,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 TransactGet object.</returns>
[Obsolete("Use the CreateTransactGet overload that takes TransactGetConfig instead, since DynamoDBOperationConfig contains properties that are not applicable to BatchGet.")]
TransactGet<T> CreateTransactGet<T>(DynamoDBOperationConfig operationConfig = null);
ITransactGet<T> CreateTransactGet<T>(DynamoDBOperationConfig operationConfig = null);

/// <summary>
/// Creates a strongly-typed TransactGet object, allowing
Expand All @@ -296,15 +296,15 @@ public partial interface IDynamoDBContext : IDisposable
/// <typeparam name="T">Type of objects to get.</typeparam>
/// <param name="transactGetConfig">Config object that can be used to override properties on the table's context for this request.</param>
/// <returns>Empty strongly-typed TransactGet object.</returns>
TransactGet<T> CreateTransactGet<T>(TransactGetConfig transactGetConfig);
ITransactGet<T> CreateTransactGet<T>(TransactGetConfig transactGetConfig);

/// <summary>
/// Creates a MultiTableTransactGet object, composed of multiple
/// individual TransactGet objects.
/// </summary>
/// <param name="transactionParts">Individual TransactGet objects.</param>
/// <returns>Composite MultiTableTransactGet object.</returns>
MultiTableTransactGet CreateMultiTableTransactGet(params TransactGet[] transactionParts);
IMultiTableTransactGet CreateMultiTableTransactGet(params ITransactGet[] transactionParts);

#endregion

Expand Down
Loading

0 comments on commit 9e67016

Please sign in to comment.