Skip to content

Commit 99556c4

Browse files
committed
Assert.EnterMultipleScope
1 parent c919852 commit 99556c4

File tree

11 files changed

+100
-100
lines changed

11 files changed

+100
-100
lines changed

AssetRipper.TextureDecoder.TestGenerator/TestClassGenerator.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private static void WriteGetMethodMatchesProperties(this IndentedTextWriter text
220220

221221
textWriter.WriteLine("var color = MakeRandomColor();");
222222
textWriter.WriteLine("color.GetChannels(out var r, out var g, out var b, out var a);");
223-
textWriter.WriteLine("Assert.Multiple(() =>");
223+
textWriter.WriteLine("using (Assert.EnterMultipleScope())");
224224
textWriter.WriteLine("{");
225225
textWriter.Indent += 1;
226226

@@ -230,7 +230,7 @@ private static void WriteGetMethodMatchesProperties(this IndentedTextWriter text
230230
}
231231

232232
textWriter.Indent -= 1;
233-
textWriter.WriteLine("});");
233+
textWriter.WriteLine("};");
234234

235235
textWriter.Indent -= 1;
236236
textWriter.WriteLine("}");
@@ -250,7 +250,7 @@ private static void WriteIndependenceTest(this IndentedTextWriter textWriter, Ge
250250
}
251251
textWriter.WriteLine($"color.{channel} = MakeRandomValue();");
252252

253-
textWriter.WriteLine("Assert.Multiple(() =>");
253+
textWriter.WriteLine("using (Assert.EnterMultipleScope())");
254254
textWriter.WriteLine("{");
255255
textWriter.Indent += 1;
256256

@@ -260,7 +260,7 @@ private static void WriteIndependenceTest(this IndentedTextWriter textWriter, Ge
260260
}
261261

262262
textWriter.Indent -= 1;
263-
textWriter.WriteLine("});");
263+
textWriter.WriteLine("};");
264264

265265
textWriter.Indent -= 1;
266266
textWriter.WriteLine("}");
@@ -310,7 +310,7 @@ private static void WriteMethodSymmetryTest(this IndentedTextWriter textWriter)
310310
textWriter.WriteLine("var color = MakeRandomColor();");
311311
textWriter.WriteLine("color.GetChannels(out var r, out var g, out var b, out var a);");
312312
textWriter.WriteLine("color.SetChannels(r, g, b, a);");
313-
textWriter.WriteLine("Assert.Multiple(() =>");
313+
textWriter.WriteLine("using (Assert.EnterMultipleScope())");
314314
textWriter.WriteLine("{");
315315
textWriter.Indent += 1;
316316

@@ -320,7 +320,7 @@ private static void WriteMethodSymmetryTest(this IndentedTextWriter textWriter)
320320
}
321321

322322
textWriter.Indent -= 1;
323-
textWriter.WriteLine("});");
323+
textWriter.WriteLine("};");
324324

325325
textWriter.Indent -= 1;
326326
textWriter.WriteLine("}");

AssetRipper.TextureDecoder.Tests/AtcTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ public void DecompressAtcRgb4Test()
99
{
1010
byte[] data = File.ReadAllBytes(TestFileFolders.AtcTestFiles + "test.atc_rgb4");
1111
int bytesRead = Atc.AtcDecoder.DecompressAtcRgb4<ColorBGRA<byte>, byte>(data, 256, 256, out byte[] decodedData);
12-
Assert.Multiple(() =>
12+
using (Assert.EnterMultipleScope())
1313
{
1414
Assert.That(bytesRead, Is.EqualTo(data.Length));
1515
Assert.That(decodedData, Is.EqualTo(File.ReadAllBytes(TestFileFolders.AtcTestFiles + "test.atc_rgb4_decoded")));
16-
});
16+
}
1717
}
1818

1919
[Test]
2020
public void DecompressAtcRgba8Test()
2121
{
2222
byte[] data = File.ReadAllBytes(TestFileFolders.AtcTestFiles + "test.atc_rgba8");
2323
int bytesRead = Atc.AtcDecoder.DecompressAtcRgba8<ColorBGRA<byte>, byte>(data, 256, 256, out byte[] decodedData);
24-
Assert.Multiple(() =>
24+
using (Assert.EnterMultipleScope())
2525
{
2626
Assert.That(bytesRead, Is.EqualTo(data.Length));
2727
Assert.That(decodedData, Is.EqualTo(File.ReadAllBytes(TestFileFolders.AtcTestFiles + "test.atc_rgba8_decoded")));
28-
});
28+
}
2929
}
3030
}
3131
}

AssetRipper.TextureDecoder.Tests/BcTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,85 +100,85 @@ public void Decompress_BC7(string fileName)
100100
[Test]
101101
public void PartialBlock_BC1([Range(1, 4)] int width, [Range(1, 4)] int height)
102102
{
103-
Assert.Multiple(() =>
103+
using (Assert.EnterMultipleScope())
104104
{
105105
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt1").AsSpan()[..Bc1.BlockSize];
106106
int bytesRead = Bc1.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
107107
Assert.That(bytesRead, Is.EqualTo(data.Length));
108108
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
109-
});
109+
}
110110
}
111111

112112
[Test]
113113
public void PartialBlock_BC2([Range(1, 4)] int width, [Range(1, 4)] int height)
114114
{
115-
Assert.Multiple(() =>
115+
using (Assert.EnterMultipleScope())
116116
{
117117
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt3").AsSpan()[..Bc2.BlockSize];
118118
int bytesRead = Bc2.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
119119
Assert.That(bytesRead, Is.EqualTo(data.Length));
120120
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
121-
});
121+
}
122122
}
123123

124124
[Test]
125125
public void PartialBlock_BC3([Range(1, 4)] int width, [Range(1, 4)] int height)
126126
{
127-
Assert.Multiple(() =>
127+
using (Assert.EnterMultipleScope())
128128
{
129129
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.DxtTestFiles + "test.dxt5").AsSpan()[..Bc3.BlockSize];
130130
int bytesRead = Bc3.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
131131
Assert.That(bytesRead, Is.EqualTo(data.Length));
132132
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
133-
});
133+
}
134134
}
135135

136136
[Test]
137137
public void PartialBlock_BC4([Range(1, 4)] int width, [Range(1, 4)] int height)
138138
{
139-
Assert.Multiple(() =>
139+
using (Assert.EnterMultipleScope())
140140
{
141141
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc4").AsSpan()[..Bc4.BlockSize];
142142
int bytesRead = Bc4.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
143143
Assert.That(bytesRead, Is.EqualTo(data.Length));
144144
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
145-
});
145+
}
146146
}
147147

148148
[Test]
149149
public void PartialBlock_BC5([Range(1, 4)] int width, [Range(1, 4)] int height)
150150
{
151-
Assert.Multiple(() =>
151+
using (Assert.EnterMultipleScope())
152152
{
153153
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc5").AsSpan()[..Bc5.BlockSize];
154154
int bytesRead = Bc5.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
155155
Assert.That(bytesRead, Is.EqualTo(data.Length));
156156
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
157-
});
157+
}
158158
}
159159

160160
[Test]
161161
public void PartialBlock_BC6H([Range(1, 4)] int width, [Range(1, 4)] int height)
162162
{
163-
Assert.Multiple(() =>
163+
using (Assert.EnterMultipleScope())
164164
{
165165
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc6h_best").AsSpan()[..Bc6h.BlockSize];
166166
int bytesRead = Bc6h.Decompress<ColorBGRA<byte>, byte>(data, width, height, false, out byte[] decodedData);
167167
Assert.That(bytesRead, Is.EqualTo(data.Length));
168168
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
169-
});
169+
}
170170
}
171171

172172
[Test]
173173
public void PartialBlock_BC7([Range(1, 4)] int width, [Range(1, 4)] int height)
174174
{
175-
Assert.Multiple(() =>
175+
using (Assert.EnterMultipleScope())
176176
{
177177
ReadOnlySpan<byte> data = File.ReadAllBytes(TestFileFolders.BcTestFiles + "test.bc7_best").AsSpan()[..Bc7.BlockSize];
178178
int bytesRead = Bc7.Decompress<ColorBGRA<byte>, byte>(data, width, height, out byte[] decodedData);
179179
Assert.That(bytesRead, Is.EqualTo(data.Length));
180180
Assert.That(decodedData, Has.Length.EqualTo(width * height * Unsafe.SizeOf<ColorBGRA<byte>>()));
181-
});
181+
}
182182
}
183183

184184
private static void AssertCorrectBC6HDecompression(string path, int width, int height, bool isSigned)

AssetRipper.TextureDecoder.Tests/ByteArrayDeviation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ internal static void AssertMinimalDeviation(byte[] decoded, byte[] original, dou
3030
double standardDeviation = Math.Sqrt(sumOfSquaredDeviations / (decoded.Length - 1));
3131
//Not sure if Bessel's correction is needed here, but it doesn't hurt, especially since length is around 1 million in the current use.
3232

33-
Assert.Multiple(() =>
33+
using (Assert.EnterMultipleScope())
3434
{
3535
Assert.That(mean, Is.LessThan(maxMeanDeviation), "Mean too far positive");
3636
Assert.That(mean, Is.GreaterThan(-maxMeanDeviation), "Mean too far negative");
3737
Assert.That(standardDeviation, Is.LessThan(maxStandardDeviation), "Standard deviation too large");
38-
});
38+
}
3939
}
4040
}

AssetRipper.TextureDecoder.Tests/Formats/ColorARGB16Tests.g.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public void ChannelsAreIndependent_R()
5757
var b = color.B;
5858
var a = color.A;
5959
color.R = MakeRandomValue();
60-
Assert.Multiple(() =>
60+
using (Assert.EnterMultipleScope())
6161
{
6262
Assert.That(color.G, Is.EqualTo(g));
6363
Assert.That(color.B, Is.EqualTo(b));
6464
Assert.That(color.A, Is.EqualTo(a));
65-
});
65+
};
6666
}
6767

6868
[Test]
@@ -73,12 +73,12 @@ public void ChannelsAreIndependent_G()
7373
var b = color.B;
7474
var a = color.A;
7575
color.G = MakeRandomValue();
76-
Assert.Multiple(() =>
76+
using (Assert.EnterMultipleScope())
7777
{
7878
Assert.That(color.R, Is.EqualTo(r));
7979
Assert.That(color.B, Is.EqualTo(b));
8080
Assert.That(color.A, Is.EqualTo(a));
81-
});
81+
};
8282
}
8383

8484
[Test]
@@ -89,12 +89,12 @@ public void ChannelsAreIndependent_B()
8989
var g = color.G;
9090
var a = color.A;
9191
color.B = MakeRandomValue();
92-
Assert.Multiple(() =>
92+
using (Assert.EnterMultipleScope())
9393
{
9494
Assert.That(color.R, Is.EqualTo(r));
9595
Assert.That(color.G, Is.EqualTo(g));
9696
Assert.That(color.A, Is.EqualTo(a));
97-
});
97+
};
9898
}
9999

100100
[Test]
@@ -105,26 +105,26 @@ public void ChannelsAreIndependent_A()
105105
var g = color.G;
106106
var b = color.B;
107107
color.A = MakeRandomValue();
108-
Assert.Multiple(() =>
108+
using (Assert.EnterMultipleScope())
109109
{
110110
Assert.That(color.R, Is.EqualTo(r));
111111
Assert.That(color.G, Is.EqualTo(g));
112112
Assert.That(color.B, Is.EqualTo(b));
113-
});
113+
};
114114
}
115115

116116
[Test]
117117
public void GetMethodMatchesProperties()
118118
{
119119
var color = MakeRandomColor();
120120
color.GetChannels(out var r, out var g, out var b, out var a);
121-
Assert.Multiple(() =>
121+
using (Assert.EnterMultipleScope())
122122
{
123123
Assert.That(color.R, Is.EqualTo(r));
124124
Assert.That(color.G, Is.EqualTo(g));
125125
Assert.That(color.B, Is.EqualTo(b));
126126
Assert.That(color.A, Is.EqualTo(a));
127-
});
127+
};
128128
}
129129

130130
[Test]
@@ -133,13 +133,13 @@ public void MethodsAreSymmetric()
133133
var color = MakeRandomColor();
134134
color.GetChannels(out var r, out var g, out var b, out var a);
135135
color.SetChannels(r, g, b, a);
136-
Assert.Multiple(() =>
136+
using (Assert.EnterMultipleScope())
137137
{
138138
Assert.That(color.R, Is.EqualTo(r));
139139
Assert.That(color.G, Is.EqualTo(g));
140140
Assert.That(color.B, Is.EqualTo(b));
141141
Assert.That(color.A, Is.EqualTo(a));
142-
});
142+
};
143143
}
144144

145145
public static ColorARGB16 MakeRandomColor() => ColorRandom<ColorARGB16, byte>.MakeRandomColor();

AssetRipper.TextureDecoder.Tests/Formats/ColorRGB16Tests.g.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public void ChannelsAreIndependent_R()
5757
var b = color.B;
5858
var a = color.A;
5959
color.R = MakeRandomValue();
60-
Assert.Multiple(() =>
60+
using (Assert.EnterMultipleScope())
6161
{
6262
Assert.That(color.G, Is.EqualTo(g));
6363
Assert.That(color.B, Is.EqualTo(b));
6464
Assert.That(color.A, Is.EqualTo(a));
65-
});
65+
};
6666
}
6767

6868
[Test]
@@ -73,12 +73,12 @@ public void ChannelsAreIndependent_G()
7373
var b = color.B;
7474
var a = color.A;
7575
color.G = MakeRandomValue();
76-
Assert.Multiple(() =>
76+
using (Assert.EnterMultipleScope())
7777
{
7878
Assert.That(color.R, Is.EqualTo(r));
7979
Assert.That(color.B, Is.EqualTo(b));
8080
Assert.That(color.A, Is.EqualTo(a));
81-
});
81+
};
8282
}
8383

8484
[Test]
@@ -89,12 +89,12 @@ public void ChannelsAreIndependent_B()
8989
var g = color.G;
9090
var a = color.A;
9191
color.B = MakeRandomValue();
92-
Assert.Multiple(() =>
92+
using (Assert.EnterMultipleScope())
9393
{
9494
Assert.That(color.R, Is.EqualTo(r));
9595
Assert.That(color.G, Is.EqualTo(g));
9696
Assert.That(color.A, Is.EqualTo(a));
97-
});
97+
};
9898
}
9999

100100
[Test]
@@ -105,26 +105,26 @@ public void ChannelsAreIndependent_A()
105105
var g = color.G;
106106
var b = color.B;
107107
color.A = MakeRandomValue();
108-
Assert.Multiple(() =>
108+
using (Assert.EnterMultipleScope())
109109
{
110110
Assert.That(color.R, Is.EqualTo(r));
111111
Assert.That(color.G, Is.EqualTo(g));
112112
Assert.That(color.B, Is.EqualTo(b));
113-
});
113+
};
114114
}
115115

116116
[Test]
117117
public void GetMethodMatchesProperties()
118118
{
119119
var color = MakeRandomColor();
120120
color.GetChannels(out var r, out var g, out var b, out var a);
121-
Assert.Multiple(() =>
121+
using (Assert.EnterMultipleScope())
122122
{
123123
Assert.That(color.R, Is.EqualTo(r));
124124
Assert.That(color.G, Is.EqualTo(g));
125125
Assert.That(color.B, Is.EqualTo(b));
126126
Assert.That(color.A, Is.EqualTo(a));
127-
});
127+
};
128128
}
129129

130130
[Test]
@@ -133,13 +133,13 @@ public void MethodsAreSymmetric()
133133
var color = MakeRandomColor();
134134
color.GetChannels(out var r, out var g, out var b, out var a);
135135
color.SetChannels(r, g, b, a);
136-
Assert.Multiple(() =>
136+
using (Assert.EnterMultipleScope())
137137
{
138138
Assert.That(color.R, Is.EqualTo(r));
139139
Assert.That(color.G, Is.EqualTo(g));
140140
Assert.That(color.B, Is.EqualTo(b));
141141
Assert.That(color.A, Is.EqualTo(a));
142-
});
142+
};
143143
}
144144

145145
public static ColorRGB16 MakeRandomColor() => ColorRandom<ColorRGB16, byte>.MakeRandomColor();

0 commit comments

Comments
 (0)