Skip to content

Commit 93e37ca

Browse files
Simplify the test.
1 parent 4c2c223 commit 93e37ca

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/NHibernate.Test/Async/NHSpecificTest/Logs/LogsFixture.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ public async Task WillGetSessionIdFromSessionLogsConcurrentAsync()
7575
using (var s = Sfi.OpenSession())
7676
{
7777
sessionIds.AddOrUpdate(
78-
Thread.CurrentThread.ManagedThreadId,
78+
i,
7979
s.GetSessionImplementation().SessionId,
80-
(tId, old) => throw new InvalidOperationException(
81-
$"Thread {tId} has already session id {old}, while attempting to set it to" +
80+
(ti, old) => throw new InvalidOperationException(
81+
$"Thread number {ti} has already session id {old}, while attempting to set it to" +
8282
$" {s.GetSessionImplementation().SessionId}"));
8383
semaphore.Wait();
8484

@@ -97,7 +97,7 @@ public async Task WillGetSessionIdFromSessionLogsConcurrentAsync()
9797
using (var spy = new TextLogSpy("NHibernate.SQL", "%message | SessionId: %property{sessionId}"))
9898
{
9999
Array.ForEach(array, thread => thread.Start());
100-
// Give some time to threads for reaching the wait, having this way all of them ready to do most of their job concurrently.
100+
// Give some time to threads for reaching the wait, having all of them ready to do most of their job concurrently.
101101
await (Task.Delay(100));
102102
semaphore.Set();
103103
Array.ForEach(array, thread => thread.Join());
@@ -108,7 +108,7 @@ public async Task WillGetSessionIdFromSessionLogsConcurrentAsync()
108108
for (var i = 1; i < 11; i++)
109109
for (var j = 0; j < 10; j++)
110110
{
111-
var sessionId = sessionIds[array[i - 1].ManagedThreadId];
111+
var sessionId = sessionIds[i];
112112
Assert.That(loggingEvent, Does.Contain($"@p0 = {i * 10 + j} [Type: Int32 (0:0:0)] | SessionId: {sessionId}"));
113113
}
114114
}

src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ public void WillGetSessionIdFromSessionLogsConcurrent()
6464
using (var s = Sfi.OpenSession())
6565
{
6666
sessionIds.AddOrUpdate(
67-
Thread.CurrentThread.ManagedThreadId,
67+
i,
6868
s.GetSessionImplementation().SessionId,
69-
(tId, old) => throw new InvalidOperationException(
70-
$"Thread {tId} has already session id {old}, while attempting to set it to" +
69+
(ti, old) => throw new InvalidOperationException(
70+
$"Thread number {ti} has already session id {old}, while attempting to set it to" +
7171
$" {s.GetSessionImplementation().SessionId}"));
7272
semaphore.Wait();
7373

@@ -86,7 +86,7 @@ public void WillGetSessionIdFromSessionLogsConcurrent()
8686
using (var spy = new TextLogSpy("NHibernate.SQL", "%message | SessionId: %property{sessionId}"))
8787
{
8888
Array.ForEach(array, thread => thread.Start());
89-
// Give some time to threads for reaching the wait, having this way all of them ready to do most of their job concurrently.
89+
// Give some time to threads for reaching the wait, having all of them ready to do most of their job concurrently.
9090
Thread.Sleep(100);
9191
semaphore.Set();
9292
Array.ForEach(array, thread => thread.Join());
@@ -97,7 +97,7 @@ public void WillGetSessionIdFromSessionLogsConcurrent()
9797
for (var i = 1; i < 11; i++)
9898
for (var j = 0; j < 10; j++)
9999
{
100-
var sessionId = sessionIds[array[i - 1].ManagedThreadId];
100+
var sessionId = sessionIds[i];
101101
Assert.That(loggingEvent, Does.Contain($"@p0 = {i * 10 + j} [Type: Int32 (0:0:0)] | SessionId: {sessionId}"));
102102
}
103103
}

0 commit comments

Comments
 (0)