Skip to content

Commit c1e4865

Browse files
committed
test: improve tests
1 parent 080b4e7 commit c1e4865

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

tests/ByteSync.Client.IntegrationTests/Services/Synchronizations/TestSynchronizationActionHandler.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ public void SetUp()
5959
}
6060

6161
[Test]
62-
public void Test_FailUnknownOperator()
62+
public async Task Test_FailUnknownOperator()
6363
{
6464
var sharedActionsGroup = new SharedActionsGroup
6565
{
6666
ActionsGroupId = "ACI_Test",
6767
};
6868

69-
FluentActions.Awaiting(() => _synchronizationActionHandler.RunSynchronizationAction(sharedActionsGroup))
69+
await FluentActions.Awaiting(() => _synchronizationActionHandler.RunSynchronizationAction(sharedActionsGroup))
7070
.Should().ThrowAsync<ApplicationException>();
7171
}
7272

@@ -501,7 +501,7 @@ public async Task Test_Create_InvalidFileSystemType_ShouldThrowException()
501501
};
502502

503503
// Should throw exception because Create operation should only work for directories
504-
FluentActions.Awaiting(() => _synchronizationActionHandler.RunSynchronizationAction(sharedActionsGroup))
504+
await FluentActions.Awaiting(() => _synchronizationActionHandler.RunSynchronizationAction(sharedActionsGroup))
505505
.Should().ThrowAsync<ApplicationException>();
506506
}
507507

@@ -532,7 +532,7 @@ public async Task Test_Delete_Directory_WithFiles_ShouldThrowIOException()
532532
};
533533

534534
// Should throw IOException when trying to delete non-empty directory with recursive=false
535-
FluentActions.Awaiting(() => _synchronizationActionHandler.RunSynchronizationAction(sharedActionsGroup))
535+
await FluentActions.Awaiting(() => _synchronizationActionHandler.RunSynchronizationAction(sharedActionsGroup))
536536
.Should().ThrowAsync<IOException>();
537537

538538
// Directory should still exist because the delete operation failed
@@ -544,7 +544,7 @@ public async Task Test_Delete_Directory_WithFiles_ShouldThrowIOException()
544544
public async Task Test_RunSynchronizationAction_CancelledImmediately_ShouldThrowOperationCancelledException()
545545
{
546546
var cancellationTokenSource = new CancellationTokenSource();
547-
cancellationTokenSource.Cancel();
547+
await cancellationTokenSource.CancelAsync();
548548

549549
var sharedActionsGroup = new SharedActionsGroup
550550
{
@@ -556,7 +556,7 @@ public async Task Test_RunSynchronizationAction_CancelledImmediately_ShouldThrow
556556
PathIdentity = new PathIdentity(FileSystemTypes.File, "/test.txt", "test.txt", "/test.txt")
557557
};
558558

559-
FluentActions.Awaiting(() => _synchronizationActionHandler.RunSynchronizationAction(sharedActionsGroup, cancellationTokenSource.Token))
559+
await FluentActions.Awaiting(() => _synchronizationActionHandler.RunSynchronizationAction(sharedActionsGroup, cancellationTokenSource.Token))
560560
.Should().ThrowAsync<OperationCanceledException>();
561561
}
562562

@@ -650,9 +650,6 @@ public async Task Test_RunSynchronizationAction_MultipleTargets_CancelledDuringP
650650

651651
var fileA = _testDirectoryService.CreateFileInDirectory(sourceA, "fileToSync.txt", "content_for_multiple");
652652

653-
var fileBPath = Path.Combine(sourceB.FullName, "fileToSync.txt");
654-
var fileCPath = Path.Combine(sourceC.FullName, "fileToSync.txt");
655-
656653
var cancellationTokenSource = new CancellationTokenSource();
657654

658655
var source = new SharedDataPart("fileToSync.txt", FileSystemTypes.Directory, _currentEndPoint.ClientInstanceId,
@@ -677,9 +674,9 @@ public async Task Test_RunSynchronizationAction_MultipleTargets_CancelledDuringP
677674
// Cancel after a short delay to potentially interrupt processing
678675
_ = Task.Run(async () =>
679676
{
680-
await Task.Delay(50);
681-
cancellationTokenSource.Cancel();
682-
});
677+
await Task.Delay(50, CancellationToken.None);
678+
await cancellationTokenSource.CancelAsync();
679+
}, cancellationTokenSource.Token).ConfigureAwait(false);
683680

684681
try
685682
{
@@ -764,7 +761,7 @@ public async Task Test_RunPendingSynchronizationActions_CancelledImmediately()
764761
var cancellationTokenSource = new CancellationTokenSource();
765762
await cancellationTokenSource.CancelAsync();
766763

767-
FluentActions.Awaiting(() => _synchronizationActionHandler.RunPendingSynchronizationActions(cancellationTokenSource.Token))
764+
await FluentActions.Awaiting(() => _synchronizationActionHandler.RunPendingSynchronizationActions(cancellationTokenSource.Token))
768765
.Should().ThrowAsync<OperationCanceledException>();
769766
}
770767
}

0 commit comments

Comments
 (0)