Skip to content

Commit 84510d6

Browse files
committed
[test] perf(tests): extract virtual DelayAsync in AddTrustedClientViewModel and override in tests
1 parent 26f5ec9 commit 84510d6

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/ByteSync.Client/ViewModels/TrustedNetworks/AddTrustedClientViewModel.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Diagnostics.CodeAnalysis;
1+
using System.Diagnostics.CodeAnalysis;
22
using System.Reactive;
33
using System.Reactive.Disposables;
44
using System.Reactive.Linq;
@@ -279,13 +279,13 @@ private async Task ValidateClient()
279279
_publicKeysManager.Trust(TrustedPublicKey);
280280

281281
ShowSuccess = true;
282-
await Task.Delay(TimeSpan.FromSeconds(3));
282+
await DelayAsync(TimeSpan.FromSeconds(3));
283283
ShowSuccess = false;
284284
}
285285
else
286286
{
287287
ShowError = true;
288-
await Task.Delay(TimeSpan.FromSeconds(3));
288+
await DelayAsync(TimeSpan.FromSeconds(3));
289289
ShowError = false;
290290
}
291291

@@ -309,7 +309,7 @@ private async Task RejectClient()
309309
var task2 = _publicKeysTruster.OnPublicKeyValidationCanceled(PublicKeyCheckData!, TrustDataParameters);
310310

311311
ShowError = true;
312-
await Task.Delay(TimeSpan.FromSeconds(3));
312+
await DelayAsync(TimeSpan.FromSeconds(3));
313313
ShowError = false;
314314

315315
await Task.WhenAll(task, task2);
@@ -330,6 +330,8 @@ private async Task Cancel()
330330
await _publicKeysTruster.OnPublicKeyValidationCanceled(PublicKeyCheckData!, TrustDataParameters);
331331
}
332332

333+
protected virtual Task DelayAsync(TimeSpan delay) => Task.Delay(delay);
334+
333335
private string[] BuildSafetyWords()
334336
{
335337
var safetyWordsComputer = new SafetyWordsComputer(SafetyWordsValues.AVAILABLE_WORDS);

0 commit comments

Comments
 (0)