Skip to content

Commit df89589

Browse files
committed
Tests updated to the latest NUnit
1 parent ea42660 commit df89589

File tree

7 files changed

+96
-117
lines changed

7 files changed

+96
-117
lines changed

ThermoRawFileParserTest/OntologyMappingTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ public void TestGetInstrumentModel()
1111
{
1212
// exact match
1313
var match = OntologyMapping.GetInstrumentModel("LTQ Orbitrap");
14-
Assert.Equals("MS:1000449", match.accession);
14+
Assert.That(match.accession, Is.EqualTo("MS:1000449"));
1515
// partial match, should return the longest partial match
1616
var partialMatch = OntologyMapping.GetInstrumentModel("LTQ Orbitrap XXL");
17-
Assert.Equals("MS:1000449", partialMatch.accession);
17+
Assert.That(partialMatch.accession, Is.EqualTo("MS:1000449"));
1818
// no match, should return the generic thermo instrument
1919
var noMatch = OntologyMapping.GetInstrumentModel("non existing model");
20-
Assert.Equals("MS:1000483", noMatch.accession);
20+
Assert.That(noMatch.accession, Is.EqualTo("MS:1000483"));
2121
}
2222
}
2323
}

ThermoRawFileParserTest/ThermoRawFileParserTest.csproj

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,66 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net8.0</TargetFramework>
6-
<ImplicitUsings>enable</ImplicitUsings>
6+
<ImplicitUsings>disable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<StartupObject></StartupObject>
99
<PlatformTarget>x64</PlatformTarget>
1010
<Platforms>x64</Platforms>
1111
</PropertyGroup>
1212

13+
<ItemGroup>
14+
<Compile Remove="Query\**" />
15+
<Compile Remove="Xic\**" />
16+
<EmbeddedResource Remove="Query\**" />
17+
<EmbeddedResource Remove="Xic\**" />
18+
<None Remove="Query\**" />
19+
<None Remove="Xic\**" />
20+
</ItemGroup>
21+
1322
<ItemGroup>
1423
<PackageReference Include="mzLib" Version="1.0.552" />
1524
<PackageReference Include="NUnit" Version="4.2.2" />
25+
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
26+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
27+
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
28+
<PrivateAssets>all</PrivateAssets>
29+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
30+
</PackageReference>
31+
<PackageReference Include="coverlet.collector" Version="6.0.2">
32+
<PrivateAssets>all</PrivateAssets>
33+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
34+
</PackageReference>
1635
</ItemGroup>
1736

1837
<ItemGroup>
1938
<ProjectReference Include="..\ThermoRawFileParser.csproj" />
2039
</ItemGroup>
2140

41+
<ItemGroup>
42+
<None Update="Data\ExtensionTest.tsv">
43+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
44+
</None>
45+
<None Update="Data\small.json">
46+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
47+
</None>
48+
<None Update="Data\small.RAW">
49+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
50+
</None>
51+
<None Update="Data\small2.RAW">
52+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
53+
</None>
54+
<None Update="Data\TestFolderMgfs\NOTRAWFILE">
55+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
56+
</None>
57+
<None Update="Data\TestFolderMgfs\small1.RAW">
58+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
59+
</None>
60+
<None Update="Data\TestFolderMgfs\small2.RAW">
61+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
62+
</None>
63+
<None Update="Data\xic_in.json">
64+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
65+
</None>
66+
</ItemGroup>
67+
2268
</Project>

ThermoRawFileParserTest/UtilTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void TestRegex()
1515
Match result = Regex.Match(filterString, pattern);
1616
if (result.Success)
1717
{
18-
Assert.Equals("961.8803", result.Groups[1].Value);
18+
Assert.That(result.Groups[1].Value, Is.EqualTo("961.8803"));
1919
}
2020
else
2121
{

ThermoRawFileParserTest/WriterTests.cs

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
using System.Xml.Serialization;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Xml.Serialization;
26
using IO.Mgf;
37
using NUnit.Framework;
48
using ThermoRawFileParser;
@@ -112,7 +116,7 @@ public void TestMgf()
112116
RawFileParser.Parse(parseInput);
113117

114118
var mgfData = Mgf.LoadAllStaticData(Path.Combine(tempFilePath, "small.mgf"));
115-
Assert.Equals(34, mgfData.NumSpectra);
119+
Assert.That(mgfData.NumSpectra, Is.EqualTo(34));
116120
}
117121

118122
[Test]
@@ -129,13 +133,13 @@ public void TestFolderMgfs()
129133
RawFileParser.Parse(parseInput);
130134

131135
var numFiles = Directory.GetFiles(tempFilePath, "*.mgf");
132-
Assert.Equals(numFiles.Length, 2);
136+
Assert.That(numFiles.Length, Is.EqualTo(2));
133137

134138
var mgfData = Mgf.LoadAllStaticData(Path.Combine(tempFilePath, "small1.mgf"));
135-
Assert.Equals(34, mgfData.NumSpectra);
139+
Assert.That(mgfData.NumSpectra, Is.EqualTo(34));
136140

137141
var mgfData2 = Mgf.LoadAllStaticData(Path.Combine(tempFilePath, "small2.mgf"));
138-
Assert.Equals(34, mgfData2.NumSpectra);
142+
Assert.That(mgfData2.NumSpectra, Is.EqualTo(34));
139143

140144
Directory.Delete(tempFilePath, true);
141145
}
@@ -156,13 +160,13 @@ public void TestMzml()
156160
var testMzMl = (mzMLType) xmlSerializer.Deserialize(new FileStream(
157161
Path.Combine(tempFilePath, "small.mzML"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
158162

159-
Assert.Equals("48", testMzMl.run.spectrumList.count);
160-
Assert.Equals(48, testMzMl.run.spectrumList.spectrum.Length);
163+
Assert.That(testMzMl.run.spectrumList.count, Is.EqualTo("48"));
164+
Assert.That(testMzMl.run.spectrumList.spectrum.Length, Is.EqualTo(48));
161165

162-
Assert.Equals("1", testMzMl.run.chromatogramList.count);
163-
Assert.Equals(1, testMzMl.run.chromatogramList.chromatogram.Length);
166+
Assert.That(testMzMl.run.chromatogramList.count, Is.EqualTo("1"));
167+
Assert.That(testMzMl.run.chromatogramList.chromatogram.Length, Is.EqualTo(1));
164168

165-
Assert.Equals(48, testMzMl.run.chromatogramList.chromatogram[0].defaultArrayLength);
169+
Assert.That(testMzMl.run.chromatogramList.chromatogram[0].defaultArrayLength, Is.EqualTo(48));
166170
}
167171

168172
[Test]
@@ -183,13 +187,13 @@ public void TestProfileMzml()
183187
var testMzMl = (mzMLType)xmlSerializer.Deserialize(new FileStream(
184188
Path.Combine(tempFilePath, "small.mzML"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
185189

186-
Assert.Equals("48", testMzMl.run.spectrumList.count);
187-
Assert.Equals(48, testMzMl.run.spectrumList.spectrum.Length);
190+
Assert.That(testMzMl.run.spectrumList.count, Is.EqualTo("48"));
191+
Assert.That(testMzMl.run.spectrumList.spectrum.Length, Is.EqualTo(48));
188192

189-
Assert.Equals("1", testMzMl.run.chromatogramList.count);
190-
Assert.Equals(1, testMzMl.run.chromatogramList.chromatogram.Length);
193+
Assert.That(testMzMl.run.chromatogramList.count, Is.EqualTo("1"));
194+
Assert.That(testMzMl.run.chromatogramList.chromatogram.Length, Is.EqualTo(1));
191195

192-
Assert.Equals(48, testMzMl.run.chromatogramList.chromatogram[0].defaultArrayLength);
196+
Assert.That(testMzMl.run.chromatogramList.chromatogram[0].defaultArrayLength, Is.EqualTo(48));
193197
}
194198

195199
[Test]
@@ -210,10 +214,10 @@ public void TestMSLevels()
210214
var testMzMl = (mzMLType)xmlSerializer.Deserialize(new FileStream(
211215
Path.Combine(tempFilePath, "small.mzML"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
212216

213-
Assert.Equals("14", testMzMl.run.spectrumList.count);
214-
Assert.Equals(14, testMzMl.run.spectrumList.spectrum.Length);
217+
Assert.That(testMzMl.run.spectrumList.count, Is.EqualTo("14"));
218+
Assert.That(testMzMl.run.spectrumList.spectrum.Length, Is.EqualTo(14));
215219

216-
Assert.Equals(48, testMzMl.run.chromatogramList.chromatogram[0].defaultArrayLength);
220+
Assert.That(testMzMl.run.chromatogramList.chromatogram[0].defaultArrayLength, Is.EqualTo(48));
217221
}
218222

219223
[Test]
@@ -234,17 +238,17 @@ public void TestIndexedMzML()
234238
var testMzMl = (indexedmzML) xmlSerializer.Deserialize(new FileStream(
235239
Path.Combine(tempFilePath, "small.mzML"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
236240

237-
Assert.Equals("48", testMzMl.mzML.run.spectrumList.count);
238-
Assert.Equals(48, testMzMl.mzML.run.spectrumList.spectrum.Length);
241+
Assert.That(testMzMl.mzML.run.spectrumList.count, Is.EqualTo("48"));
242+
Assert.That(testMzMl.mzML.run.spectrumList.spectrum.Length, Is.EqualTo(48));
239243

240-
Assert.Equals("1", testMzMl.mzML.run.chromatogramList.count);
241-
Assert.Equals(1, testMzMl.mzML.run.chromatogramList.chromatogram.Length);
244+
Assert.That(testMzMl.mzML.run.chromatogramList.count, Is.EqualTo("1"));
245+
Assert.That(testMzMl.mzML.run.chromatogramList.chromatogram.Length, Is.EqualTo(1));
242246

243-
Assert.Equals(2, testMzMl.indexList.index.Length);
244-
Assert.Equals("spectrum", testMzMl.indexList.index[0].name.ToString());
245-
Assert.Equals(48, testMzMl.indexList.index[0].offset.Length);
246-
Assert.Equals("chromatogram", testMzMl.indexList.index[1].name.ToString());
247-
Assert.Equals(1, testMzMl.indexList.index[1].offset.Length);
247+
Assert.That(testMzMl.indexList.index.Length, Is.EqualTo(2));
248+
Assert.That(testMzMl.indexList.index[0].name.ToString(), Is.EqualTo("spectrum"));
249+
Assert.That(testMzMl.indexList.index[0].offset.Length, Is.EqualTo(48));
250+
Assert.That(testMzMl.indexList.index[1].name.ToString(), Is.EqualTo("chromatogram"));
251+
Assert.That(testMzMl.indexList.index[1].offset.Length, Is.EqualTo(1));
248252
}
249253

250254
[Test]
@@ -263,19 +267,19 @@ public void TestMzML_MS2()
263267
var testMzMl = (mzMLType)xmlSerializer.Deserialize(new FileStream(
264268
Path.Combine(tempFilePath, "small2.mzML"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
265269

266-
Assert.Equals(95, testMzMl.run.spectrumList.spectrum.Length);
270+
Assert.That(testMzMl.run.spectrumList.spectrum.Length, Is.EqualTo(95));
267271

268272
var precursor = testMzMl.run.spectrumList.spectrum[16].precursorList.precursor[0].selectedIonList.selectedIon[0];
269273
var selectedMz = Double.Parse(precursor.cvParam.Where(cv => cv.accession == "MS:1000744").First().value);
270274
Assert.That(selectedMz - 604.7592 < 0.001);
271275

272276
var selectedZ = int.Parse(precursor.cvParam.Where(cv => cv.accession == "MS:1000041").First().value);
273-
Assert.Equals(selectedZ , 2);
277+
Assert.That(selectedZ, Is.EqualTo(2));
274278

275279
//var selectedI = Double.Parse(precursor.cvParam.Where(cv => cv.accession == "MS:1000042").First().value);
276280
//Assert.IsTrue(selectedI - 10073 < 1);
277281

278-
Assert.Equals(95, testMzMl.run.chromatogramList.chromatogram[0].defaultArrayLength);
282+
Assert.That(testMzMl.run.chromatogramList.chromatogram[0].defaultArrayLength, Is.EqualTo(95));
279283
}
280284
}
281285
}

ThermoRawFileParserTest/XicReaderTests.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
14
using NUnit.Framework;
25
using ThermoFisher.CommonCore.Data;
36
using ThermoRawFileParser;
@@ -34,8 +37,8 @@ public void testXicReadFullRange()
3437

3538
XicReader.ReadXic(testRawFile, false, xicData, ref xicparams);
3639
XicUnit xicUnit = xicData.Content[0];
37-
Assert.Equals(14, ((Array) xicUnit.RetentionTimes).Length);
38-
Assert.Equals(14, ((Array) xicUnit.Intensities).Length);
40+
Assert.That(((Array)xicUnit.RetentionTimes).Length, Is.EqualTo(14));
41+
Assert.That(((Array)xicUnit.Intensities).Length, Is.EqualTo(14));
3942
Assert.That(Math.Abs(140 - xicUnit.Meta.MzStart.Value) < 0.01);
4043
Assert.That(Math.Abs(2000 - xicUnit.Meta.MzEnd.Value) < 0.01);
4144
Assert.That(Math.Abs(0.004935 - xicUnit.Meta.RtStart.Value) < 0.01);
@@ -68,8 +71,8 @@ public void testXicRead()
6871

6972
XicReader.ReadXic(testRawFile, false, xicData, ref xicparams);
7073
XicUnit xicUnit = xicData.Content[0];
71-
Assert.Equals(46, ((Array) xicUnit.RetentionTimes).Length);
72-
Assert.Equals(46, ((Array) xicUnit.Intensities).Length);
74+
Assert.That(((Array)xicUnit.RetentionTimes).Length, Is.EqualTo(46));
75+
Assert.That(((Array)xicUnit.Intensities).Length, Is.EqualTo(46));
7376
Assert.That(Math.Abs(749.786 - xicUnit.Meta.MzStart.Value) < 0.01);
7477
Assert.That(Math.Abs(749.8093 - xicUnit.Meta.MzEnd.Value) < 0.01);
7578
Assert.That(Math.Abs(10 - xicUnit.Meta.RtStart.Value) < 0.01);
@@ -94,8 +97,8 @@ public void testXicRead()
9497
};
9598
XicReader.ReadXic(testRawFile, false, xicData, ref xicparams);
9699
xicUnit = xicData.Content[0];
97-
Assert.Equals(1, ((Array) xicUnit.RetentionTimes).Length);
98-
Assert.Equals(1, ((Array) xicUnit.Intensities).Length);
100+
Assert.That(((Array)xicUnit.RetentionTimes).Length, Is.EqualTo(1));
101+
Assert.That(((Array)xicUnit.Intensities).Length, Is.EqualTo(1));
99102
Assert.That(Math.Abs(749.786 - xicUnit.Meta.MzStart.Value) < 0.01);
100103
Assert.That(Math.Abs(749.8093 - xicUnit.Meta.MzEnd.Value) < 0.01);
101104
Assert.That(Math.Abs(300 - xicUnit.Meta.RtStart.Value) < 0.01);
@@ -167,7 +170,7 @@ public void testValidateJson()
167170
// test a json with 2 missing properties
168171
errors = JSONParser.ValidateJson(json);
169172
Assert.That(!errors.IsNullOrEmpty());
170-
Assert.Equals(2, errors.Count);
173+
Assert.That(errors.Count, Is.EqualTo(2));
171174

172175
json = @"[
173176
{
@@ -197,7 +200,7 @@ public void testValidateJson()
197200
// test a json with 2 negative numbers
198201
errors = JSONParser.ValidateJson(json);
199202
Assert.That(!errors.IsNullOrEmpty());
200-
Assert.Equals(2, errors.Count);
203+
Assert.That(errors.Count, Is.EqualTo(2));
201204
}
202205

203206
[Test]

ThermoRawFileParserTest/app.config

Lines changed: 0 additions & 51 deletions
This file was deleted.

ThermoRawFileParserTest/log4net.config

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)