diff --git a/src/Foundatio.TestHarness/Caching/CacheClientTestsBase.cs b/src/Foundatio.TestHarness/Caching/CacheClientTestsBase.cs index d2157820..f61ae1a2 100644 --- a/src/Foundatio.TestHarness/Caching/CacheClientTestsBase.cs +++ b/src/Foundatio.TestHarness/Caching/CacheClientTestsBase.cs @@ -690,7 +690,7 @@ public virtual async Task CanManageListsAsync() { await cache.ListRemoveAsync("test1", new[] { 1, 2, 3 }); result = await cache.GetListAsync("test1"); Assert.NotNull(result); - Assert.Equal(0, result.Value.Count); + Assert.Empty(result.Value); // test single strings don't get handled as char arrays await cache.RemoveAllAsync(); @@ -722,7 +722,7 @@ public virtual async Task CanManageListsAsync() { await cache.ListRemoveAsync("test1", 3); result = await cache.GetListAsync("test1"); Assert.NotNull(result); - Assert.Equal(0, result.Value.Count); + Assert.Empty(result.Value); await Assert.ThrowsAnyAsync(async () => { await cache.AddAsync("key1", 1); diff --git a/src/Foundatio.TestHarness/Messaging/MessageBusTestBase.cs b/src/Foundatio.TestHarness/Messaging/MessageBusTestBase.cs index 0d763e28..1f580d0b 100644 --- a/src/Foundatio.TestHarness/Messaging/MessageBusTestBase.cs +++ b/src/Foundatio.TestHarness/Messaging/MessageBusTestBase.cs @@ -381,7 +381,7 @@ public virtual async Task WillOnlyReceiveSubscribedMessageTypeAsync() { try { var countdown = new AsyncCountdownEvent(1); await messageBus.SubscribeAsync(msg => { - Assert.True(false, "Received wrong message type"); + Assert.Fail("Received wrong message type"); }); await messageBus.SubscribeAsync(msg => { Assert.Equal("Hello", msg.Data); @@ -517,10 +517,10 @@ public virtual async Task CanCancelSubscriptionAsync() { long messageCount = 0; var cancellationTokenSource = new CancellationTokenSource(); - await messageBus.SubscribeAsync(msg => { + await messageBus.SubscribeAsync(async msg => { _logger.LogTrace("SimpleAMessage received"); Interlocked.Increment(ref messageCount); - cancellationTokenSource.Cancel(); + await cancellationTokenSource.CancelAsync(); countdown.Signal(); }, cancellationTokenSource.Token); diff --git a/src/Foundatio.TestHarness/Storage/FileStorageTestsBase.cs b/src/Foundatio.TestHarness/Storage/FileStorageTestsBase.cs index 97cdd7f4..43a0cfab 100644 --- a/src/Foundatio.TestHarness/Storage/FileStorageTestsBase.cs +++ b/src/Foundatio.TestHarness/Storage/FileStorageTestsBase.cs @@ -71,7 +71,7 @@ public virtual async Task CanGetFileListForSingleFileAsync() { await storage.SaveFileAsync(@"q\new.txt", "new"); await storage.SaveFileAsync(@"long/path/in/here/1.hey.stuff-2.json", "archived"); - Assert.Equal(1, (await storage.GetFileListAsync(@"archived\archived.txt")).Count); + Assert.Single(await storage.GetFileListAsync(@"archived\archived.txt")); } } @@ -85,26 +85,26 @@ public virtual async Task CanGetPagedFileListForSingleFolderAsync() { using (storage) { var result = await storage.GetPagedFileListAsync(1); Assert.False(result.HasMore); - Assert.Equal(0, result.Files.Count); + Assert.Empty(result.Files); Assert.False(await result.NextPageAsync()); Assert.False(result.HasMore); - Assert.Equal(0, result.Files.Count); + Assert.Empty(result.Files); await storage.SaveFileAsync(@"archived\archived.txt", "archived"); result = await storage.GetPagedFileListAsync(1); Assert.False(result.HasMore); - Assert.Equal(1, result.Files.Count); + Assert.Single(result.Files); Assert.False(await result.NextPageAsync()); Assert.False(result.HasMore); - Assert.Equal(1, result.Files.Count); + Assert.Single(result.Files); await storage.SaveFileAsync(@"q\new.txt", "new"); result = await storage.GetPagedFileListAsync(1); Assert.True(result.HasMore); - Assert.Equal(1, result.Files.Count); + Assert.Single(result.Files); Assert.True(await result.NextPageAsync()); Assert.False(result.HasMore); - Assert.Equal(1, result.Files.Count); + Assert.Single(result.Files); await storage.SaveFileAsync(@"long/path/in/here/1.hey.stuff-2.json", "archived"); diff --git a/tests/Foundatio.Tests/Jobs/WorkItemJobTests.cs b/tests/Foundatio.Tests/Jobs/WorkItemJobTests.cs index 4896e748..4f729c39 100644 --- a/tests/Foundatio.Tests/Jobs/WorkItemJobTests.cs +++ b/tests/Foundatio.Tests/Jobs/WorkItemJobTests.cs @@ -111,15 +111,15 @@ await messageBus.SubscribeAsync(status => { var tasks = new List { Task.Run(async () => { await j1.RunUntilEmptyAsync(cancellationTokenSource.Token); - cancellationTokenSource.Cancel(); + await cancellationTokenSource.CancelAsync(); }, cancellationTokenSource.Token), Task.Run(async () => { await j2.RunUntilEmptyAsync(cancellationTokenSource.Token); - cancellationTokenSource.Cancel(); + await cancellationTokenSource.CancelAsync(); }, cancellationTokenSource.Token), Task.Run(async () => { await j3.RunUntilEmptyAsync(cancellationTokenSource.Token); - cancellationTokenSource.Cancel(); + await cancellationTokenSource.CancelAsync(); }, cancellationTokenSource.Token) };