Skip to content

Commit 0d92dd8

Browse files
authored
Fix NUnit2050 warnings in tests (#3522)
1 parent 3e1c0f0 commit 0d92dd8

File tree

48 files changed

+143
-148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+143
-148
lines changed

.editorconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ dotnet_diagnostic.NUnit2006.severity = suggestion
2525
dotnet_diagnostic.NUnit2015.severity = suggestion
2626
dotnet_diagnostic.NUnit2031.severity = suggestion
2727
dotnet_diagnostic.NUnit2049.severity = suggestion
28-
# NUnit 4 no longer supports string.Format specification for Assert
29-
dotnet_diagnostic.NUnit2050.severity = suggestion
3028
# The SameAs constraint always fails on value types as the actual and the expected value cannot be the same reference
3129
dotnet_diagnostic.NUnit2040.severity = suggestion
3230

src/NHibernate.Test/Async/Criteria/Lambda/IntegrationFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ public async Task MultiCriteriaAsync()
358358
{
359359
var driver = Sfi.ConnectionProvider.Driver;
360360
if (!driver.SupportsMultipleQueries)
361-
Assert.Ignore("Driver {0} does not support multi-queries", driver.GetType().FullName);
361+
Assert.Ignore($"Driver {driver.GetType().FullName} does not support multi-queries");
362362

363363
await (SetupPagingDataAsync());
364364

src/NHibernate.Test/Async/Criteria/ProjectionsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public async Task UsingSqlFunctions_Concat_WithCastAsync()
9191
{
9292
if(Dialect is Oracle8iDialect)
9393
{
94-
Assert.Ignore("Not supported by the active dialect:{0}.", Dialect);
94+
Assert.Ignore($"Not supported by the active dialect:{Dialect}.");
9595
}
9696
if (TestDialect.HasBrokenTypeInferenceOnSelectedParameters)
9797
Assert.Ignore("Current dialect does not support this test");

src/NHibernate.Test/Async/Criteria/SelectModeTest/SelectModeTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ public async Task FetchModeEagerForEagerAsync()
663663
private void SkipFutureTestIfNotSupported()
664664
{
665665
if (Sfi.ConnectionProvider.Driver.SupportsMultipleQueries == false)
666-
Assert.Ignore("Driver {0} does not support multi-queries", Sfi.ConnectionProvider.Driver.GetType().FullName);
666+
Assert.Ignore($"Driver {Sfi.ConnectionProvider.Driver.GetType().FullName} does not support multi-queries");
667667
}
668668

669669
#region Test Setup

src/NHibernate.Test/Async/Extralazy/ExtraLazyFixture.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public async Task ListAddAsync(bool initialize)
114114
// Have to skip unloaded (non-queued indeed) elements to avoid triggering existence queries on them.
115115
foreach (var item in addedItems.Skip(5))
116116
{
117-
Assert.That(gavin.Companies.Contains(item), Is.True, "Company '{0}' existence", item.Name);
117+
Assert.That(gavin.Companies.Contains(item), Is.True, $"Company '{item.Name}' existence");
118118
}
119119

120120
Assert.That(Sfi.Statistics.FlushCount, Is.EqualTo(0), "Flushes count after checking existence of non-flushed");
@@ -322,7 +322,7 @@ public async Task ListInsertAsync(bool initialize)
322322
// Have to skip unloaded (non-queued indeed) elements to avoid triggering existence queries on them.
323323
foreach (var item in addedItems.Skip(5))
324324
{
325-
Assert.That(gavin.Companies.Contains(item), Is.True, "Company '{0}' existence", item.Name);
325+
Assert.That(gavin.Companies.Contains(item), Is.True, $"Company '{item.Name}' existence");
326326
}
327327

328328
Assert.That(Sfi.Statistics.FlushCount, Is.EqualTo(0), "Flushes count after existence check");
@@ -636,7 +636,7 @@ public async Task ListGetSetAsync(bool initialize)
636636
Sfi.Statistics.Clear();
637637
for (var i = 0; i < 10; i++)
638638
{
639-
Assert.That(gavin.Companies[i], Is.EqualTo(addedItems[i]), "Comparing added company at index {0}", i);
639+
Assert.That(gavin.Companies[i], Is.EqualTo(addedItems[i]), $"Comparing added company at index {i}");
640640
}
641641

642642
Assert.That(Sfi.Statistics.FlushCount, Is.EqualTo(0), "Flushes count after adding comparing");
@@ -676,7 +676,7 @@ public async Task ListGetSetAsync(bool initialize)
676676
Sfi.Statistics.Clear();
677677
for (var i = 0; i < 10; i++)
678678
{
679-
Assert.That(gavin.Companies[i].ListIndex, Is.EqualTo(finalIndexOrder[i]), "Comparing company ListIndex at index {0}", i);
679+
Assert.That(gavin.Companies[i].ListIndex, Is.EqualTo(finalIndexOrder[i]), $"Comparing company ListIndex at index {i}");
680680
}
681681

682682
Assert.That(Sfi.Statistics.FlushCount, Is.EqualTo(0), "Flushes count after comparing");
@@ -798,7 +798,7 @@ public async Task ListFlushAsync(bool initialize)
798798
{
799799
for (var i = 15; i < 20; i++)
800800
{
801-
Assert.That(gavin.Companies.Remove(addedItems[i]), Is.True, "Removing transient company at index {0}", i);
801+
Assert.That(gavin.Companies.Remove(addedItems[i]), Is.True, $"Removing transient company at index {i}");
802802
}
803803

804804
Assert.That(FindAllOccurrences(sqlLog.GetWholeLog(), "INSERT \n INTO"), Is.EqualTo(10), "Statements count after removing");
@@ -909,7 +909,7 @@ public async Task ListFlushAsync(bool initialize)
909909

910910
for (var i = 0; i < gavin.Companies.Count; i++)
911911
{
912-
Assert.That(gavin.Companies[i].ListIndex, Is.EqualTo(i), "Comparing company ListIndex at index {0}", i);
912+
Assert.That(gavin.Companies[i].ListIndex, Is.EqualTo(i), $"Comparing company ListIndex at index {i}");
913913
}
914914

915915
if (initialize)
@@ -1049,7 +1049,7 @@ public async Task ListClearAsync(bool initialize)
10491049
Assert.That(collection.Count, Is.EqualTo(6), "Credit cards count after loading again Gavin");
10501050
for (var i = 0; i < 10; i++)
10511051
{
1052-
Assert.That(collection.Contains(addedItems[i]), i < 6 ? Is.True : (IResolveConstraint) Is.False, "Checking existence for item at {0}", i);
1052+
Assert.That(collection.Contains(addedItems[i]), i < 6 ? Is.True : (IResolveConstraint) Is.False, $"Checking existence for item at {i}");
10531053
}
10541054

10551055
Assert.That(NHibernateUtil.IsInitialized(collection), Is.False, "Credit cards initialization status after loading again");
@@ -1140,7 +1140,7 @@ public async Task ListIndexOperationsAsync(bool initialize)
11401140

11411141
for (var i = 0; i < gavin.Companies.Count; i++)
11421142
{
1143-
Assert.That(gavin.Companies[i].OriginalIndex, Is.EqualTo(finalIndexOrder[i]), "Comparing company index at {0}", i);
1143+
Assert.That(gavin.Companies[i].OriginalIndex, Is.EqualTo(finalIndexOrder[i]), $"Comparing company index at {i}");
11441144
}
11451145

11461146
if (initialize)
@@ -1882,8 +1882,7 @@ public async Task SetClearAsync(bool initialize)
18821882
Assert.That(collection.Count, Is.EqualTo(6), "Permissions count after loading again Gavin");
18831883
for (var i = 0; i < 10; i++)
18841884
{
1885-
Assert.That(collection.Contains(addedItems[i]), i < 6 ? Is.True : (IResolveConstraint) Is.False,
1886-
"Checking existence of added element at {0}", i);
1885+
Assert.That(collection.Contains(addedItems[i]), i < 6 ? Is.True : (IResolveConstraint) Is.False, $"Checking existence of added element at {i}");
18871886
}
18881887

18891888
Assert.That(NHibernateUtil.IsInitialized(collection), Is.False, "Permissions initialization status after loading again");

src/NHibernate.Test/Async/Hql/Ast/BulkManipulation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ public async Task SimpleDeleteOnAnimalAsync()
884884
{
885885
if (Dialect.HasSelfReferentialForeignKeyBug)
886886
{
887-
Assert.Ignore("self referential FK bug", "HQL delete testing");
887+
Assert.Ignore("self referential FK bug - HQL delete testing");
888888
return;
889889
}
890890

src/NHibernate.Test/Async/IdGen/NativeGuid/NativeGuidGeneratorFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public async Task ReturnedValueIsGuidAsync()
4343
}
4444
catch (NotSupportedException)
4545
{
46-
Assert.Ignore("This test does not apply to {0}", Dialect.Dialect.GetDialect());
46+
Assert.Ignore($"This test does not apply to {Dialect.Dialect.GetDialect()}");
4747
}
4848

4949
var gen = new NativeGuidGenerator();

src/NHibernate.Test/Async/Linq/FunctionTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ where lowerName.IndexOf('a') == 0
204204
select lowerName;
205205
var result = await (query.ToListAsync());
206206

207-
Assert.That(result, Is.EqualTo(expected), "Expected {0} but was {1}", string.Join("|", expected), string.Join("|", result));
207+
Assert.That(result, Is.EqualTo(expected), $"Expected {string.Join("|", expected)} but was {string.Join("|", result)}");
208208
await (ObjectDumper.WriteAsync(query));
209209
}
210210

@@ -220,7 +220,7 @@ where lowerName.IndexOf('a', 2) == -1
220220
select lowerName;
221221
var result = await (query.ToListAsync());
222222

223-
Assert.That(result, Is.EqualTo(expected), "Expected {0} but was {1}", string.Join("|", expected), string.Join("|", result));
223+
Assert.That(result, Is.EqualTo(expected), $"Expected {string.Join("|", expected)} but was {string.Join("|", result)}");
224224
await (ObjectDumper.WriteAsync(query));
225225
}
226226

@@ -236,7 +236,7 @@ where lowerName.IndexOf("an") == 0
236236
select lowerName;
237237
var result = await (query.ToListAsync());
238238

239-
Assert.That(result, Is.EqualTo(expected), "Expected {0} but was {1}", string.Join("|", expected), string.Join("|", result));
239+
Assert.That(result, Is.EqualTo(expected), $"Expected {string.Join("|", expected)} but was {string.Join("|", result)}");
240240
await (ObjectDumper.WriteAsync(query));
241241
}
242242

@@ -252,7 +252,7 @@ where lowerName.Contains("a")
252252
select lowerName.IndexOf("a", 1);
253253
var result = await (query.ToListAsync());
254254

255-
Assert.That(result, Is.EqualTo(expected), "Expected {0} but was {1}", string.Join("|", expected), string.Join("|", result));
255+
Assert.That(result, Is.EqualTo(expected), $"Expected {string.Join("|", expected)} but was {string.Join("|", result)}");
256256
await (ObjectDumper.WriteAsync(query));
257257
}
258258

src/NHibernate.Test/Async/NHSpecificTest/NH1253/Fixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public async Task MultiQuerySingleInListAsync()
8585
{
8686
var driver = Sfi.ConnectionProvider.Driver;
8787
if (!driver.SupportsMultipleQueries)
88-
Assert.Ignore("Driver {0} does not support multi-queries", driver.GetType().FullName);
88+
Assert.Ignore($"Driver {driver.GetType().FullName} does not support multi-queries");
8989

9090
using (var s = OpenSession())
9191
using (var tx = s.BeginTransaction())

src/NHibernate.Test/Async/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public async Task LoadEntityCollectionWithCustomLoaderAsync()
244244
[Test]
245245
public async Task NativeUpdateQueryWithoutResultsAsync()
246246
{
247-
Assume.That(Dialect, Is.InstanceOf<MsSql2000Dialect>(), "This does not apply to {0}", Dialect);
247+
Assume.That(Dialect, Is.InstanceOf<MsSql2000Dialect>(), $"This does not apply to {Dialect}");
248248
Assume.That(WithQueryCache, Is.False, "This test does not use a cacheable query.");
249249
using (ISession session = OpenSession())
250250
{
@@ -259,7 +259,7 @@ public async Task NativeUpdateQueryWithoutResultsAsync()
259259
[Test]
260260
public async Task NativeScalarQueryWithoutResultsAsync()
261261
{
262-
Assume.That(Dialect, Is.InstanceOf<MsSql2000Dialect>(), "This does not apply to {0}", Dialect);
262+
Assume.That(Dialect, Is.InstanceOf<MsSql2000Dialect>(), $"This does not apply to {Dialect}");
263263
Assume.That(WithQueryCache, Is.False, "This test does not use a cacheable query.");
264264
using (ISession session = OpenSession())
265265
{
@@ -278,7 +278,7 @@ public async Task NativeScalarQueryWithUndefinedResultsetAsync()
278278
{
279279
if (!(Dialect is MsSql2000Dialect))
280280
{
281-
Assert.Ignore("This does not apply to {0}", Dialect);
281+
Assert.Ignore($"This does not apply to {Dialect}");
282282
}
283283
using (ISession session = OpenSession())
284284
{
@@ -301,7 +301,7 @@ public async Task NativeScalarQueryWithDefinedResultsetAsync()
301301
{
302302
if (!(Dialect is MsSql2000Dialect))
303303
{
304-
Assert.Ignore("This does not apply to {0}", Dialect);
304+
Assert.Ignore($"This does not apply to {Dialect}");
305305
}
306306
using (ISession session = OpenSession())
307307
{

0 commit comments

Comments
 (0)