Skip to content

Commit 4b439ba

Browse files
authored
Merge pull request #135 from TheBoxyBear/111-bump-package-versions-for-unit-test-project
#111 Bump packages
2 parents 18c234a + d1a3498 commit 4b439ba

File tree

6 files changed

+67
-93
lines changed

6 files changed

+67
-93
lines changed

ChartTools/ChartTools.Tests/ChartTools.Tests.csproj

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
13-
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
14-
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
15-
<PackageReference Include="coverlet.collector" Version="6.0.0">
16-
<PrivateAssets>all</PrivateAssets>
17-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
18-
</PackageReference>
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
13+
<PackageReference Include="MSTest.TestAdapter" Version="4.1.0" />
14+
<PackageReference Include="MSTest.TestFramework" Version="4.1.0" />
1915
</ItemGroup>
2016

2117
<ItemGroup>

ChartTools/ChartTools.Tests/Extensions/Collections/Alternating/OrderedAlternatingTests.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
using ChartTools.Extensions.Collections.Alternating;
22

3-
using Microsoft.VisualStudio.TestTools.UnitTesting;
4-
53
using System.Collections;
64

75
namespace ChartTools.Tests.Extensions.Collections.Alternating;
86

97
[TestClass]
108
public class OrderedAlternatingTests
119
{
12-
static readonly Func<byte, byte> keyGetter = n => n;
10+
static readonly Func<byte, byte> keyGetter = static n => n;
1311

1412
static readonly byte[]
1513
testArrayA = [1, 6, 2],
@@ -18,13 +16,13 @@ static readonly byte[]
1816

1917
[TestMethod, TestCategory("Ctor"), TestCategory(nameof(Exception))]
2018
public void Ctor_NullKeyGetter_Throws()
21-
=> Assert.ThrowsException<ArgumentNullException>(
22-
() => new OrderedAlternatingEnumerable<byte, byte>(null!, []));
19+
=> Assert.Throws<ArgumentNullException>(
20+
static () => new OrderedAlternatingEnumerable<byte, byte>(null!, []));
2321

2422
[TestMethod, TestCategory("Ctor"), TestCategory(nameof(Exception))]
2523
public void Ctor_NoEnumerables_Throws()
26-
=> Assert.ThrowsException<ArgumentException>(
27-
() => new OrderedAlternatingEnumerable<byte, byte>(keyGetter));
24+
=> Assert.Throws<ArgumentException>(
25+
static () => new OrderedAlternatingEnumerable<byte, byte>(keyGetter));
2826

2927
[TestMethod, TestCategory(nameof(IEnumerable.GetEnumerator))]
3028
public void Enumerate_SequenceEquals()

ChartTools/ChartTools.Tests/Extensions/Collections/Alternating/SerialAlternatingTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ static readonly byte[]
1616

1717
[TestMethod, TestCategory("Ctor"), TestCategory(nameof(Exception))]
1818
public void Ctor_NoEnumerables_Throws()
19-
=> Assert.ThrowsException<ArgumentException>(
20-
() => new SerialAlternatingEnumerable<byte>());
19+
=> Assert.Throws<ArgumentException>(
20+
static () => new SerialAlternatingEnumerable<byte>());
2121

2222
[TestMethod, TestCategory(nameof(IEnumerable.GetEnumerator))]
2323
public void Enumerate_SequenceEquals()

ChartTools/ChartTools.Tests/Meta/MetadataTests.cs

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,72 +5,70 @@
55
using ChartTools.IO.Ini;
66
using ChartTools.Meta;
77

8-
using Microsoft.VisualStudio.TestTools.UnitTesting;
9-
108
using System.Reflection;
119

1210
namespace ChartTools.Tests.Meta;
1311

1412
[TestClass]
1513
public class MetadataTests
1614
{
17-
private readonly Metadata invalidDummy = new();
15+
private static readonly Metadata s_invalidDummy = new();
1816

1917
#region Invalid format
2018
[TestMethod, TestCategory(nameof(Metadata)), TestCategory(nameof(Exception))]
2119
public void TryGet_InvalidFormat_Throws()
22-
=> Assert.ThrowsException<ArgumentException>(
23-
() => invalidDummy.TryGet(FileType.Midi, "Dummy", out _));
20+
=> Assert.Throws<ArgumentException>(
21+
static () => s_invalidDummy.TryGet(FileType.Midi, "Dummy", out _));
2422

2523
[TestMethod, TestCategory(nameof(Metadata.Get)), TestCategory(nameof(Exception))]
2624
public void Get_InvalidFormat_Throws()
27-
=> Assert.ThrowsException<ArgumentException>(
28-
() => invalidDummy.Get(FileType.Midi, "Dummy"));
25+
=> Assert.Throws<ArgumentException>(
26+
static () => s_invalidDummy.Get(FileType.Midi, "Dummy"));
2927

3028
[TestMethod, TestCategory(nameof(Metadata.Set)), TestCategory(nameof(Exception))]
3129
public void Set_InvalidFormat_Throws()
32-
=> Assert.ThrowsException<ArgumentException>(
33-
() => invalidDummy.Set(FileType.Midi, string.Empty, string.Empty));
30+
=> Assert.Throws<ArgumentException>(
31+
static () => s_invalidDummy.Set(FileType.Midi, string.Empty, string.Empty));
3432

3533
[TestMethod, TestCategory(nameof(Metadata.Remove)), TestCategory(nameof(Exception))]
3634
public void Remove_InvalidFormat_Throws()
37-
=> Assert.ThrowsException<ArgumentException>(
38-
() => invalidDummy.Remove(FileType.Midi, "Dummy"));
35+
=> Assert.Throws<ArgumentException>(
36+
static () => s_invalidDummy.Remove(FileType.Midi, "Dummy"));
3937

4038
[TestMethod, TestCategory(nameof(Metadata.Remove)), TestCategory(nameof(Exception))]
4139
public void Contains_InvalidFormat_Throws()
42-
=> Assert.ThrowsException<ArgumentException>(
43-
() => invalidDummy.Contains(FileType.Midi, "Dummy"));
40+
=> Assert.Throws<ArgumentException>(
41+
static () => s_invalidDummy.Contains(FileType.Midi, "Dummy"));
4442
#endregion
4543

4644
#region Empty key
4745
[TestMethod, TestCategory(nameof(Metadata.Get))]
4846
[TestCategory(nameof(FileType.Chart)), TestCategory(nameof(FileType.Ini))]
4947
[DataRow(FileType.Chart), DataRow(FileType.Ini)]
5048
public void Get_EmptyKey_Throws(FileType fileType)
51-
=> Assert.ThrowsException<ArgumentException>(
52-
() => invalidDummy.Get(fileType, string.Empty));
49+
=> Assert.Throws<ArgumentException>(
50+
() => s_invalidDummy.Get(fileType, string.Empty));
5351

5452
[TestMethod, TestCategory(nameof(Metadata.Set)),
5553
TestCategory(nameof(FileType.Chart)), TestCategory(nameof(FileType.Ini))]
5654
[DataRow(FileType.Chart), DataRow(FileType.Ini)]
5755
public void Set_EmptyKey_Throws(FileType fileType)
58-
=> Assert.ThrowsException<ArgumentException>(
59-
() => invalidDummy.Set(fileType, string.Empty, "Dummy"));
56+
=> Assert.Throws<ArgumentException>(
57+
() => s_invalidDummy.Set(fileType, string.Empty, "Dummy"));
6058

6159
[TestMethod, TestCategory(nameof(Metadata.Remove))]
6260
[TestCategory(nameof(FileType.Chart)), TestCategory(nameof(FileType.Ini))]
6361
[DataRow(FileType.Chart), DataRow(FileType.Ini)]
6462
public void Remove_EmptyKey_Throws(FileType fileType)
65-
=> Assert.ThrowsException<ArgumentException>(
66-
() => invalidDummy.Remove(fileType, string.Empty));
63+
=> Assert.Throws<ArgumentException>(
64+
() => s_invalidDummy.Remove(fileType, string.Empty));
6765

6866
[TestMethod, TestCategory(nameof(Metadata.Contains))]
6967
[TestCategory(nameof(FileType.Chart)), TestCategory(nameof(FileType.Ini))]
7068
[DataRow(FileType.Chart), DataRow(FileType.Ini)]
7169
public void Contains_EmptyKey_Throws(FileType fileType)
72-
=> Assert.ThrowsException<ArgumentException>(
73-
() => invalidDummy.Contains(fileType, string.Empty));
70+
=> Assert.Throws<ArgumentException>(
71+
() => s_invalidDummy.Contains(fileType, string.Empty));
7472
#endregion
7573

7674
#region FromAttribute
@@ -165,11 +163,8 @@ public void Set_AudioOffet_Formats(FileType fileType, string key, string value)
165163
[DataRow(FileType.Chart, ChartFormatting.AudioOffset)]
166164
[DataRow(FileType.Ini, IniFormatting.AudioOffset)]
167165
public void Set_AudioOffsetInvalid_Throws(FileType fileType, string key)
168-
=> Assert.ThrowsException<ParseException>(() =>
169-
{
170-
Metadata metadata = new();
171-
metadata.Set(fileType, key, "InvalidOffset");
172-
});
166+
=> Assert.Throws<ParseException>(
167+
() => new Metadata().Set(fileType, key, "InvalidOffset"));
173168
#endregion
174169

175170
#region Chart year
@@ -178,7 +173,7 @@ public void Set_AudioOffsetInvalid_Throws(FileType fileType, string key)
178173
public void Get_ChartYear_Formats()
179174
{
180175
const ushort year = 2000;
181-
string expected = $"\", {year}\"";
176+
string expected = $"\", {year}\"";
182177

183178
Metadata metadata = new() { Year = year };
184179

@@ -190,7 +185,7 @@ public void Get_ChartYear_Formats()
190185
public void Set_ChartYear_Formats()
191186
{
192187
const ushort expected = 2000;
193-
string formatted = $"\", {expected}\"";
188+
string formatted = $"\", {expected}\"";
194189

195190
Metadata metadata = new();
196191
metadata.Set(FileType.Chart, ChartFormatting.Year, formatted);
@@ -201,11 +196,8 @@ public void Set_ChartYear_Formats()
201196
[TestMethod, TestCategory(nameof(Exception)), TestCategory(nameof(FileType.Chart))]
202197
[TestCategory(nameof(Metadata.Set)), TestCategory(nameof(Metadata.Year))]
203198
public void Set_ChartYearInvalid_Throws()
204-
=> Assert.ThrowsException<ParseException>(() =>
205-
{
206-
Metadata metadata = new();
207-
metadata.Set(FileType.Chart, ChartFormatting.Year, "InvalidYear");
208-
});
199+
=> Assert.Throws<ParseException>(
200+
static () => new Metadata().Set(FileType.Chart, ChartFormatting.Year, "InvalidYear"));
209201
#endregion
210202

211203
#region Ini
@@ -240,22 +232,17 @@ public void Set_IniVideoOffset_Formats(double milliseconds)
240232
[TestMethod, TestCategory(nameof(Exception)), TestCategory(nameof(FileType.Ini))]
241233
[TestCategory(nameof(Metadata.Set)), TestCategory(nameof(Metadata.VideoOffset))]
242234
public void Set_IniVideoOffsetInvalid_Throws()
243-
=> Assert.ThrowsException<ParseException>(() =>
244-
{
245-
Metadata metadata = new();
246-
metadata.Set(FileType.Ini, IniFormatting.VideoOffset, "InvalidOffet");
247-
});
235+
=> Assert.Throws<ParseException>(
236+
static () => new Metadata().Set(FileType.Ini, IniFormatting.VideoOffset, "InvalidOffet"));
248237
#endregion
249238

250239
#region Modchart
251240
[TestMethod, TestCategory(nameof(FileType.Ini))]
252241
[TestCategory(nameof(Metadata.Get)), TestCategory(nameof(Metadata.IsModchart))]
253242
[DataRow(false, "0"), DataRow(true, "1")]
254243
public void Get_IniModChart_Formats(bool value, string expected)
255-
{
256-
Metadata metadata = new() { IsModchart = value };
257-
Assert.AreEqual(expected, metadata.Get(FileType.Ini, IniFormatting.Modchart));
258-
}
244+
=> Assert.AreEqual(expected, new Metadata { IsModchart = value }
245+
.Get(FileType.Ini, IniFormatting.Modchart));
259246

260247
[TestMethod, TestCategory(nameof(FileType.Ini))]
261248
[TestCategory(nameof(Metadata.Set)), TestCategory(nameof(Metadata.IsModchart))]
@@ -271,11 +258,8 @@ public void Set_IniModChart_Formats(bool expected, string value)
271258
[TestMethod, TestCategory(nameof(Exception)), TestCategory(nameof(FileType.Ini))]
272259
[TestCategory(nameof(Metadata.Set)), TestCategory(nameof(Metadata.IsModchart))]
273260
public void Set_IniModChartInvalid_Throws()
274-
=> Assert.ThrowsException<ParseException>(() =>
275-
{
276-
Metadata metadata = new();
277-
metadata.Set(FileType.Ini, IniFormatting.Modchart, "InvalidBool");
278-
});
261+
=> Assert.Throws<ParseException>(
262+
static () => new Metadata().Set(FileType.Ini, IniFormatting.Modchart, "InvalidBool"));
279263
#endregion
280264

281265
#region Album track
@@ -339,7 +323,7 @@ public void Set_IniTrack_Maps(AlbumTrackKeys keys, string keyString)
339323
[TestMethod, TestCategory(nameof(Exception)), TestCategory(nameof(FileType.Ini))]
340324
[TestCategory(nameof(Metadata.Set)), TestCategory(nameof(Metadata.AlbumTrack))]
341325
public void Set_IniTrackInvalid_Throws()
342-
=> Assert.ThrowsException<ParseException>(
326+
=> Assert.Throws<ParseException>(
343327
() => new Metadata { Formatting = new() { AlbumTrackKeys = AlbumTrackKeys.Track } }
344328
.Set(FileType.Ini, IniFormatting.Track, "InvalidTrack"));
345329

ChartTools/ChartTools.Tests/Notes/LaneNoteCollectionTests.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
2-
3-
using Lane = ChartTools.StandardLane;
1+
using Lane = ChartTools.StandardLane;
42
using Note = ChartTools.LaneNote<ChartTools.StandardLane>;
53
using NoteCollection = ChartTools.LaneNoteCollection<ChartTools.LaneNote<ChartTools.StandardLane>, ChartTools.StandardLane>;
64

@@ -12,7 +10,7 @@ public class LaneNoteCollectionTests
1210
#region Add
1311
[TestMethod, TestCategory(nameof(NoteCollection.Add)), TestCategory(nameof(Exception))]
1412
public void Add_InvalidLane_Throws()
15-
=> Assert.ThrowsException<UndefinedEnumException>(
13+
=> Assert.Throws<UndefinedEnumException>(
1614
static () => new NoteCollection().Add((Lane)10));
1715

1816
[TestMethod, TestCategory(nameof(NoteCollection.Add))]
@@ -58,7 +56,7 @@ public void Add_LaneMatch_Replaces()
5856
[TestMethod, TestCategory(nameof(NoteCollection.Add))]
5957
public void Add_NoteMatch_Replaces()
6058
{
61-
const Lane lane = Lane.Green;
59+
const Lane lane = Lane.Green;
6260
const uint sustain = 100;
6361

6462
NoteCollection collection = [new Note(lane) { Sustain = sustain }];
@@ -76,7 +74,7 @@ public void Add_NoteMatch_Replaces()
7674
#region AddRange
7775
[TestMethod, TestCategory(nameof(NoteCollection.AddRange)), TestCategory(nameof(Exception))]
7876
public void AddRange_InvalidLane_Throws()
79-
=> Assert.ThrowsException<UndefinedEnumException>(
77+
=> Assert.Throws<UndefinedEnumException>(
8078
() => new NoteCollection().AddRange((Lane)10, (Lane)11));
8179

8280
[TestMethod, TestCategory(nameof(NoteCollection.AddRange))]
@@ -167,7 +165,7 @@ public void AddRange_NoteMatch_Replaces()
167165
[TestMethod, TestCategory("Init")]
168166
public void Init_Note_Adds()
169167
{
170-
const Lane lane = Lane.Green;
168+
const Lane lane = Lane.Green;
171169
const uint sustain = 100;
172170

173171
NoteCollection collection = [new Note(lane) { Sustain = sustain }];
@@ -215,7 +213,7 @@ public void Clear_Empties()
215213
#region Contains
216214
[TestMethod, TestCategory(nameof(NoteCollection.Contains)), TestCategory(nameof(Exception))]
217215
public void Contains_InvalidLane_Throws()
218-
=> Assert.ThrowsException<UndefinedEnumException>(
216+
=> Assert.Throws<UndefinedEnumException>(
219217
() => new NoteCollection().Contains((Lane)10));
220218

221219
[TestMethod, TestCategory(nameof(NoteCollection.Contains))]
@@ -245,7 +243,7 @@ public void Contains_MatchNote_ReturnsNote()
245243
#region Remove
246244
[TestMethod, TestCategory(nameof(NoteCollection.Remove)), TestCategory(nameof(Exception))]
247245
public void Remove_InvalidLane_Throws()
248-
=> Assert.ThrowsException<UndefinedEnumException>(
246+
=> Assert.Throws<UndefinedEnumException>(
249247
static () => new NoteCollection().Remove((Lane)10));
250248

251249
[TestMethod, TestCategory(nameof(NoteCollection.Remove))]
@@ -274,8 +272,8 @@ public void Remove_NoMatch_NoRemoveReturnsFalse()
274272
#region Indexer
275273
[TestMethod, TestCategory("Indexer"), TestCategory(nameof(Exception))]
276274
public void Indexer_InvalidLane_Throws()
277-
=> Assert.ThrowsException<UndefinedEnumException>(
278-
static () => _ = new NoteCollection()[(Lane)10]);
275+
=> Assert.Throws<UndefinedEnumException>(
276+
static () => _ = new NoteCollection()[(Lane)10]);
279277

280278
[TestMethod, TestCategory("Indexer")]
281279
public void Indexer_Match_ReturnsNote()
@@ -304,7 +302,7 @@ public void Indexer_NoMatch_ReturnsNull()
304302
#region Proxy
305303
[TestMethod, TestCategory(nameof(NoteCollection.Proxy)), TestCategory(nameof(Exception))]
306304
public void Proxy_InvalidLane_Throws()
307-
=> Assert.ThrowsException<UndefinedEnumException>(
305+
=> Assert.Throws<UndefinedEnumException>(
308306
static () => new NoteCollection().Proxy((Lane)10));
309307

310308
[TestMethod, TestCategory(nameof(NoteCollection.Proxy))]
@@ -328,7 +326,7 @@ public void Proxy_Match_ReturnsProxy()
328326
#region ProxyAll
329327
[TestMethod, TestCategory(nameof(NoteCollection.ProxyAll))]
330328
public void ProxyAll_Empty_ReturnsEmpty()
331-
=> Assert.AreEqual(0, new NoteCollection().ProxyAll().Length);
329+
=> Assert.IsEmpty(new NoteCollection().ProxyAll());
332330

333331
[TestMethod, TestCategory(nameof(NoteCollection.ProxyAll))]
334332
public void ProxyAll_ReturnsProxies()
@@ -338,7 +336,7 @@ public void ProxyAll_ReturnsProxies()
338336
NoteCollection collection = [new Note(Lane.Green), new Note(Lane.Red)];
339337
NoteProxy<Note, Lane>[] proxies = collection.ProxyAll();
340338

341-
Assert.AreEqual(lanes.Length, proxies.Length);
339+
Assert.HasCount(lanes.Length, proxies);
342340

343341
for (int i = 0; i < lanes.Length; i++)
344342
{

0 commit comments

Comments
 (0)