Skip to content

Commit a768cd1

Browse files
added a test case to test direct batchId rehydration
1 parent f4c0d4c commit a768cd1

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

tests/Batch/BatchTests.cs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,9 @@ public async Task CreateGetAndCancelBatchProtocol()
153153
Assert.That(status, Is.EqualTo("validating"));
154154
}
155155

156-
[Test]
157-
public async Task CanRehydrateBatchOperation()
156+
[TestCase(true)]
157+
[TestCase(false)]
158+
public async Task CanRehydrateBatchOperation(bool useBatchId)
158159
{
159160
using MemoryStream testFileStream = new();
160161
using StreamWriter streamWriter = new(testFileStream);
@@ -183,13 +184,22 @@ public async Task CanRehydrateBatchOperation()
183184
? await client.CreateBatchAsync(content, waitUntilCompleted: false)
184185
: client.CreateBatch(content, waitUntilCompleted: false);
185186

186-
// Simulate rehydration of the operation
187-
BinaryData rehydrationBytes = batchOperation.RehydrationToken.ToBytes();
188-
ContinuationToken rehydrationToken = ContinuationToken.FromBytes(rehydrationBytes);
189-
190-
CreateBatchOperation rehydratedOperation = IsAsync ?
191-
await CreateBatchOperation.RehydrateAsync(client, rehydrationToken) :
192-
CreateBatchOperation.Rehydrate(client, rehydrationToken);
187+
CreateBatchOperation rehydratedOperation;
188+
if (useBatchId)
189+
{
190+
rehydratedOperation = IsAsync ?
191+
await CreateBatchOperation.RehydrateAsync(client, batchOperation.BatchId) :
192+
CreateBatchOperation.Rehydrate(client, batchOperation.BatchId);
193+
}
194+
else {
195+
// Simulate rehydration of the operation
196+
BinaryData rehydrationBytes = batchOperation.RehydrationToken.ToBytes();
197+
ContinuationToken rehydrationToken = ContinuationToken.FromBytes(rehydrationBytes);
198+
199+
rehydratedOperation = IsAsync ?
200+
await CreateBatchOperation.RehydrateAsync(client, rehydrationToken) :
201+
CreateBatchOperation.Rehydrate(client, rehydrationToken);
202+
}
193203

194204
static bool Validate(CreateBatchOperation operation)
195205
{

0 commit comments

Comments
 (0)