This is an automated email from the ASF dual-hosted git repository.

blankensteiner pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-dotpulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new cb252b7  Should fix tests and warnings
cb252b7 is described below

commit cb252b7580077b9a13f9d45e3f687cb5376d8f84
Author: Daniel Blankensteiner <[email protected]>
AuthorDate: Tue Sep 19 08:57:17 2023 +0200

    Should fix tests and warnings
---
 src/DotPulsar/Internal/Connection.cs               |  6 +--
 tests/DotPulsar.Tests/ConsumerTests.cs             |  6 +--
 tests/DotPulsar.Tests/Internal/AsyncLockTests.cs   | 44 +++++++++++-----------
 tests/DotPulsar.Tests/Internal/AsyncQueueTests.cs  | 20 +++++-----
 .../Internal/AsyncQueueWithCursorTests.cs          |  2 +-
 .../DotPulsar.Tests/Internal/StateManagerTests.cs  |  4 +-
 6 files changed, 39 insertions(+), 43 deletions(-)

diff --git a/src/DotPulsar/Internal/Connection.cs 
b/src/DotPulsar/Internal/Connection.cs
index 4faae41..952ece9 100644
--- a/src/DotPulsar/Internal/Connection.cs
+++ b/src/DotPulsar/Internal/Connection.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -95,9 +95,7 @@ public sealed class Connection : IConnection
 
         if (_authentication is not null)
         {
-            if (command.Response is null)
-                command.Response = new AuthData();
-
+            command.Response ??= new AuthData();
             command.Response.AuthMethodName = 
_authentication.AuthenticationMethodName;
             command.Response.Data = await 
_authentication.GetAuthenticationData(cancellationToken).ConfigureAwait(false);
         }
diff --git a/tests/DotPulsar.Tests/ConsumerTests.cs 
b/tests/DotPulsar.Tests/ConsumerTests.cs
index 4b446e1..4f7414d 100644
--- a/tests/DotPulsar.Tests/ConsumerTests.cs
+++ b/tests/DotPulsar.Tests/ConsumerTests.cs
@@ -204,7 +204,7 @@ public class ConsumerTests
         var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60));
 
         //Act
-        var produced = await ProduceMessages(producer, numberOfMessages, 
cts.Token, content);
+        var produced = await ProduceMessages(producer, numberOfMessages, 
content, cts.Token);
         var consumed = await ConsumeMessages(consumer, numberOfMessages, 
cts.Token);
 
         //Assert
@@ -231,7 +231,7 @@ public class ConsumerTests
         var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60));
 
         //Act
-        var produced = await ProduceMessages(producer, numberOfMessages, 
cts.Token, content);
+        var produced = await ProduceMessages(producer, numberOfMessages, 
content, cts.Token);
         var consumed = await ConsumeMessages(consumer, numberOfMessages, 
cts.Token);
 
         //Assert
@@ -285,7 +285,7 @@ public class ConsumerTests
         exception.Should().BeOfType<ConsumerFaultedException>();
     }
 
-    private static async Task<IEnumerable<MessageId>> 
ProduceMessages(IProducer<string> producer, int numberOfMessages, 
CancellationToken ct, string content)
+    private static async Task<IEnumerable<MessageId>> 
ProduceMessages(IProducer<string> producer, int numberOfMessages, string 
content, CancellationToken ct)
     {
         var messageIds = new MessageId[numberOfMessages];
 
diff --git a/tests/DotPulsar.Tests/Internal/AsyncLockTests.cs 
b/tests/DotPulsar.Tests/Internal/AsyncLockTests.cs
index 4eae9e8..f21818f 100644
--- a/tests/DotPulsar.Tests/Internal/AsyncLockTests.cs
+++ b/tests/DotPulsar.Tests/Internal/AsyncLockTests.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -28,7 +28,7 @@ public class AsyncLockTests
     public async Task Lock_GivenLockIsFree_ShouldReturnCompletedTask()
     {
         //Arrange
-        var sut = new AsyncLock();
+        await using var sut = new AsyncLock();
 
         //Act
         var actual = sut.Lock(CancellationToken.None);
@@ -37,16 +37,15 @@ public class AsyncLockTests
         actual.IsCompleted.Should().BeTrue();
 
         //Annihilate 
-        actual.Result.Dispose();
-        await sut.DisposeAsync().ConfigureAwait(false);
+        (await actual).Dispose();
     }
 
     [Fact]
     public async Task Lock_GivenLockIsTaken_ShouldReturnIncompletedTask()
     {
         //Arrange
-        var sut = new AsyncLock();
-        var alreadyTaken = await 
sut.Lock(CancellationToken.None).ConfigureAwait(false);
+        await using var sut = new AsyncLock();
+        var alreadyTaken = await sut.Lock(CancellationToken.None);
 
         //Act
         var actual = sut.Lock(CancellationToken.None);
@@ -56,8 +55,7 @@ public class AsyncLockTests
 
         //Annihilate
         alreadyTaken.Dispose();
-        actual.Result.Dispose();
-        await sut.DisposeAsync().ConfigureAwait(false);
+        (await actual).Dispose();
     }
 
     [Fact]
@@ -65,10 +63,10 @@ public class AsyncLockTests
     {
         //Arrange
         var sut = new AsyncLock();
-        await sut.DisposeAsync().ConfigureAwait(false);
+        await sut.DisposeAsync();
 
         //Act
-        var exception = await Record.ExceptionAsync(() => 
sut.Lock(CancellationToken.None)).ConfigureAwait(false);
+        var exception = await Record.ExceptionAsync(() => 
sut.Lock(CancellationToken.None));
 
         //Assert
         exception.Should().BeOfType<AsyncLockDisposedException>();
@@ -79,18 +77,18 @@ public class AsyncLockTests
     {
         //Arrange
         var sut = new AsyncLock();
-        var gotLock = await 
sut.Lock(CancellationToken.None).ConfigureAwait(false);
+        var gotLock = await sut.Lock(CancellationToken.None);
         var awaiting = sut.Lock(CancellationToken.None);
-        _ = Task.Run(async () => await 
sut.DisposeAsync().ConfigureAwait(false));
+        _ = Task.Run(async () => await sut.DisposeAsync());
 
         //Act
-        var exception = await Record.ExceptionAsync(() => 
awaiting).ConfigureAwait(false);
+        var exception = await Record.ExceptionAsync(() => awaiting);
 
         //Assert
         exception.Should().BeOfType<TaskCanceledException>();
 
         //Annihilate
-        await sut.DisposeAsync().ConfigureAwait(false);
+        await sut.DisposeAsync();
         gotLock.Dispose();
     }
 
@@ -100,12 +98,12 @@ public class AsyncLockTests
         //Arrange
         var cts = new CancellationTokenSource();
         var sut = new AsyncLock();
-        var gotLock = await 
sut.Lock(CancellationToken.None).ConfigureAwait(false);
+        var gotLock = await sut.Lock(CancellationToken.None);
         var awaiting = sut.Lock(cts.Token);
 
         //Act
         cts.Cancel();
-        var exception = await Record.ExceptionAsync(() => 
awaiting).ConfigureAwait(false);
+        var exception = await Record.ExceptionAsync(() => awaiting);
 
         //Assert
         exception.Should().BeOfType<TaskCanceledException>();
@@ -113,7 +111,7 @@ public class AsyncLockTests
         //Annihilate
         cts.Dispose();
         gotLock.Dispose();
-        await sut.DisposeAsync().ConfigureAwait(false);
+        await sut.DisposeAsync();
     }
 
     [Fact]
@@ -121,19 +119,19 @@ public class AsyncLockTests
     {
         //Arrange
         var sut = new AsyncLock();
-        var gotLock = await 
sut.Lock(CancellationToken.None).ConfigureAwait(false);
-        var disposeTask = Task.Run(async () => await 
sut.DisposeAsync().ConfigureAwait(false));
+        var gotLock = await sut.Lock(CancellationToken.None);
+        var disposeTask = Task.Run(async () => await sut.DisposeAsync());
         Assert.False(disposeTask.IsCompleted);
 
         //Act
         gotLock.Dispose();
-        await disposeTask.ConfigureAwait(false);
+        await disposeTask;
 
         //Assert
         disposeTask.IsCompleted.Should().BeTrue();
 
         //Annihilate
-        await sut.DisposeAsync().ConfigureAwait(false);
+        await sut.DisposeAsync();
     }
 
     [Fact]
@@ -143,8 +141,8 @@ public class AsyncLockTests
         var sut = new AsyncLock();
 
         //Act
-        await sut.DisposeAsync().ConfigureAwait(false);
-        var exception = await Record.ExceptionAsync(() => 
sut.DisposeAsync().AsTask()).ConfigureAwait(false); // xUnit can't record 
ValueTask yet
+        await sut.DisposeAsync();
+        var exception = await Record.ExceptionAsync(() => 
sut.DisposeAsync().AsTask()); // xUnit can't record ValueTask yet
 
         //Assert
         exception.Should().BeNull();
diff --git a/tests/DotPulsar.Tests/Internal/AsyncQueueTests.cs 
b/tests/DotPulsar.Tests/Internal/AsyncQueueTests.cs
index 44247a9..fa1972c 100644
--- a/tests/DotPulsar.Tests/Internal/AsyncQueueTests.cs
+++ b/tests/DotPulsar.Tests/Internal/AsyncQueueTests.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -33,7 +33,7 @@ public class AsyncQueueTests
         queue.Enqueue(expected);
 
         //Act
-        var actual = await dequeueTask.ConfigureAwait(false);
+        var actual = await dequeueTask;
 
         //Assert
         actual.Should().Be(expected);
@@ -51,7 +51,7 @@ public class AsyncQueueTests
         queue.Enqueue(expected);
 
         //Act
-        var actual = await queue.Dequeue().ConfigureAwait(false);
+        var actual = await queue.Dequeue();
 
         //Assert
         actual.Should().Be(expected);
@@ -72,8 +72,8 @@ public class AsyncQueueTests
         queue.Enqueue(expected2);
 
         //Act
-        var actual1 = await dequeue1.ConfigureAwait(false);
-        var actual2 = await dequeue2.ConfigureAwait(false);
+        var actual1 = await dequeue1;
+        var actual2 = await dequeue2;
 
         //Assert
         actual1.Should().Be(expected1);
@@ -93,8 +93,8 @@ public class AsyncQueueTests
         queue.Enqueue(expected2);
 
         //Act
-        var actual1 = await queue.Dequeue().ConfigureAwait(false);
-        var actual2 = await queue.Dequeue().ConfigureAwait(false);
+        var actual1 = await queue.Dequeue();
+        var actual2 = await queue.Dequeue();
 
         //Assert
         actual1.Should().Be(expected1);
@@ -117,12 +117,12 @@ public class AsyncQueueTests
         //Act
         source1.Cancel();
         queue.Enqueue(excepted);
-        var exception = await Record.ExceptionAsync(() => 
task1).ConfigureAwait(false);
-        await task2.ConfigureAwait(false);
+        var exception = await Record.ExceptionAsync(() => task1);
+        var actual = await task2;
 
         //Assert
         exception.Should().BeOfType<TaskCanceledException>();
-        task2.Result.Should().Be(excepted);
+        actual.Should().Be(excepted);
 
         //Annihilate
         source1.Dispose();
diff --git a/tests/DotPulsar.Tests/Internal/AsyncQueueWithCursorTests.cs 
b/tests/DotPulsar.Tests/Internal/AsyncQueueWithCursorTests.cs
index 7a1ac38..15dae7f 100644
--- a/tests/DotPulsar.Tests/Internal/AsyncQueueWithCursorTests.cs
+++ b/tests/DotPulsar.Tests/Internal/AsyncQueueWithCursorTests.cs
@@ -170,7 +170,7 @@ public class AsyncQueueWithCursorTests
         //Act
         var pendingEnqueue = sut.Enqueue(Substitute.For<IDisposable>(), 
cts.Token).AsTask();
         cts.Cancel();
-        var exception = await Record.ExceptionAsync(() => 
pendingEnqueue).ConfigureAwait(false);
+        var exception = await Record.ExceptionAsync(() => pendingEnqueue);
 
         //Assert
         exception.Should().BeOfType<TaskCanceledException>();
diff --git a/tests/DotPulsar.Tests/Internal/StateManagerTests.cs 
b/tests/DotPulsar.Tests/Internal/StateManagerTests.cs
index 8ac34cb..b1559c6 100644
--- a/tests/DotPulsar.Tests/Internal/StateManagerTests.cs
+++ b/tests/DotPulsar.Tests/Internal/StateManagerTests.cs
@@ -1,4 +1,4 @@
-/*
+/*
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -235,7 +235,7 @@ public class StateManagerTests
 
         //Act
         cts.Cancel();
-        var exception = await Record.ExceptionAsync(() => 
task.AsTask()).ConfigureAwait(false); // xUnit can't record ValueTask yet
+        var exception = await Record.ExceptionAsync(() => task.AsTask()); // 
xUnit can't record ValueTask yet
 
         //Assert
         exception.Should().BeOfType<TaskCanceledException>();

Reply via email to