Skip to content

Commit db15872

Browse files
committed
Code style changes.
1 parent 0dc1cb8 commit db15872

File tree

2 files changed

+103
-274
lines changed

2 files changed

+103
-274
lines changed

tests/Magick.NET.Tests/MagickImageCollectionTests/ThePingMethod.cs

Lines changed: 62 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,19 @@ public class WithByteArray
2626
[Fact]
2727
public void ShouldThrowExceptionWhenArrayIsNull()
2828
{
29-
Assert.Throws<ArgumentNullException>("data", () =>
29+
using (var images = new MagickImageCollection())
3030
{
31-
using (var images = new MagickImageCollection())
32-
{
33-
images.Ping((byte[])null);
34-
}
35-
});
31+
Assert.Throws<ArgumentNullException>("data", () => images.Ping((byte[])null));
32+
}
3633
}
3734

3835
[Fact]
3936
public void ShouldThrowExceptionWhenArrayIsEmpty()
4037
{
41-
Assert.Throws<ArgumentException>("data", () =>
38+
using (var images = new MagickImageCollection())
4239
{
43-
using (var images = new MagickImageCollection())
44-
{
45-
images.Ping(new byte[0]);
46-
}
47-
});
40+
Assert.Throws<ArgumentException>("data", () => images.Ping(new byte[0]));
41+
}
4842
}
4943

5044
[Fact]
@@ -71,61 +65,46 @@ public class WithByteArrayAndOffset
7165
[Fact]
7266
public void ShouldThrowExceptionWhenArrayIsNull()
7367
{
74-
Assert.Throws<ArgumentNullException>("data", () =>
68+
using (var images = new MagickImageCollection())
7569
{
76-
using (var images = new MagickImageCollection())
77-
{
78-
images.Ping((byte[])null, 0, 0);
79-
}
80-
});
70+
Assert.Throws<ArgumentNullException>("data", () => images.Ping(null, 0, 0));
71+
}
8172
}
8273

8374
[Fact]
8475
public void ShouldThrowExceptionWhenArrayIsEmpty()
8576
{
86-
Assert.Throws<ArgumentException>("data", () =>
77+
using (var images = new MagickImageCollection())
8778
{
88-
using (var images = new MagickImageCollection())
89-
{
90-
images.Ping(new byte[] { }, 0, 0);
91-
}
92-
});
79+
Assert.Throws<ArgumentException>("data", () => images.Ping(new byte[] { }, 0, 0));
80+
}
9381
}
9482

9583
[Fact]
9684
public void ShouldThrowExceptionWhenOffsetIsNegative()
9785
{
98-
Assert.Throws<ArgumentException>("offset", () =>
86+
using (var images = new MagickImageCollection())
9987
{
100-
using (var images = new MagickImageCollection())
101-
{
102-
images.Ping(new byte[] { 215 }, -1, 0);
103-
}
104-
});
88+
Assert.Throws<ArgumentException>("offset", () => images.Ping(new byte[] { 215 }, -1, 0));
89+
}
10590
}
10691

10792
[Fact]
10893
public void ShouldThrowExceptionWhenCountIsZero()
10994
{
110-
Assert.Throws<ArgumentException>("count", () =>
95+
using (var images = new MagickImageCollection())
11196
{
112-
using (var images = new MagickImageCollection())
113-
{
114-
images.Ping(new byte[] { 215 }, 0, 0);
115-
}
116-
});
97+
Assert.Throws<ArgumentException>("count", () => images.Ping(new byte[] { 215 }, 0, 0));
98+
}
11799
}
118100

119101
[Fact]
120102
public void ShouldThrowExceptionWhenCountIsNegative()
121103
{
122-
Assert.Throws<ArgumentException>("count", () =>
104+
using (var images = new MagickImageCollection())
123105
{
124-
using (var images = new MagickImageCollection())
125-
{
126-
images.Ping(new byte[] { 215 }, 0, -1);
127-
}
128-
});
106+
Assert.Throws<ArgumentException>("count", () => images.Ping(new byte[] { 215 }, 0, -1));
107+
}
129108
}
130109

131110
[Fact]
@@ -148,71 +127,56 @@ public class WithByteArrayAndOffsetAndMagickReadSettings
148127
[Fact]
149128
public void ShouldThrowExceptionWhenArrayIsNull()
150129
{
151-
Assert.Throws<ArgumentNullException>("data", () =>
152-
{
153-
var settings = new MagickReadSettings();
130+
var settings = new MagickReadSettings();
154131

155-
using (var images = new MagickImageCollection())
156-
{
157-
images.Ping(null, 0, 0, settings);
158-
}
159-
});
132+
using (var images = new MagickImageCollection())
133+
{
134+
Assert.Throws<ArgumentNullException>("data", () => images.Ping(null, 0, 0, settings));
135+
}
160136
}
161137

162138
[Fact]
163139
public void ShouldThrowExceptionWhenArrayIsEmpty()
164140
{
165-
Assert.Throws<ArgumentException>("data", () =>
166-
{
167-
var settings = new MagickReadSettings();
141+
var settings = new MagickReadSettings();
168142

169-
using (var images = new MagickImageCollection())
170-
{
171-
images.Ping(new byte[] { }, 0, 0, settings);
172-
}
173-
});
143+
using (var images = new MagickImageCollection())
144+
{
145+
Assert.Throws<ArgumentException>("data", () => images.Ping(new byte[] { }, 0, 0, settings));
146+
}
174147
}
175148

176149
[Fact]
177150
public void ShouldThrowExceptionWhenOffsetIsNegative()
178151
{
179-
Assert.Throws<ArgumentException>("offset", () =>
180-
{
181-
var settings = new MagickReadSettings();
152+
var settings = new MagickReadSettings();
182153

183-
using (var images = new MagickImageCollection())
184-
{
185-
images.Ping(new byte[] { 215 }, -1, 0, settings);
186-
}
187-
});
154+
using (var images = new MagickImageCollection())
155+
{
156+
Assert.Throws<ArgumentException>("offset", () => images.Ping(new byte[] { 215 }, -1, 0, settings));
157+
}
188158
}
189159

190160
[Fact]
191161
public void ShouldThrowExceptionWhenCountIsZero()
192162
{
193-
Assert.Throws<ArgumentException>("count", () =>
194-
{
195-
var settings = new MagickReadSettings();
163+
var settings = new MagickReadSettings();
196164

197-
using (var images = new MagickImageCollection())
198-
{
199-
images.Ping(new byte[] { 215 }, 0, 0, settings);
200-
}
201-
});
165+
using (var images = new MagickImageCollection())
166+
{
167+
Assert.Throws<ArgumentException>("count", () => images.Ping(new byte[] { 215 }, 0, 0, settings));
168+
}
202169
}
203170

204171
[Fact]
205172
public void ShouldThrowExceptionWhenCountIsNegative()
206173
{
207-
Assert.Throws<ArgumentException>("count", () =>
208-
{
209-
var settings = new MagickReadSettings();
174+
var settings = new MagickReadSettings();
210175

211-
using (var images = new MagickImageCollection())
212-
{
213-
images.Ping(new byte[] { 215 }, 0, -1, settings);
214-
}
215-
});
176+
using (var images = new MagickImageCollection())
177+
{
178+
Assert.Throws<ArgumentException>("count", () => images.Ping(new byte[] { 215 }, 0, -1, settings));
179+
}
216180
}
217181

218182
[Fact]
@@ -264,13 +228,10 @@ public class WithFileInfo
264228
[Fact]
265229
public void ShouldThrowExceptionWhenFileInfoIsNull()
266230
{
267-
Assert.Throws<ArgumentNullException>("file", () =>
231+
using (var images = new MagickImageCollection())
268232
{
269-
using (var images = new MagickImageCollection())
270-
{
271-
images.Ping((FileInfo)null);
272-
}
273-
});
233+
Assert.Throws<ArgumentNullException>("file", () => images.Ping((FileInfo)null));
234+
}
274235
}
275236
}
276237

@@ -295,39 +256,30 @@ public class WithFileName
295256
[Fact]
296257
public void ShouldThrowExceptionWhenFileNameIsNull()
297258
{
298-
Assert.Throws<ArgumentNullException>("fileName", () =>
259+
using (var images = new MagickImageCollection())
299260
{
300-
using (var images = new MagickImageCollection())
301-
{
302-
images.Ping((string)null);
303-
}
304-
});
261+
Assert.Throws<ArgumentNullException>("fileName", () => images.Ping((string)null));
262+
}
305263
}
306264

307265
[Fact]
308266
public void ShouldThrowExceptionWhenFileNameIsEmpty()
309267
{
310-
Assert.Throws<ArgumentException>("fileName", () =>
268+
using (var images = new MagickImageCollection())
311269
{
312-
using (var images = new MagickImageCollection())
313-
{
314-
images.Ping(string.Empty);
315-
}
316-
});
270+
Assert.Throws<ArgumentException>("fileName", () => images.Ping(string.Empty));
271+
}
317272
}
318273

319274
[Fact]
320275
public void ShouldThrowExceptionWhenFileNameIsInvalid()
321276
{
322-
var exception = Assert.Throws<MagickBlobErrorException>(() =>
277+
using (var images = new MagickImageCollection())
323278
{
324-
using (var images = new MagickImageCollection())
325-
{
326-
images.Ping(Files.Missing);
327-
}
328-
});
279+
var exception = Assert.Throws<MagickBlobErrorException>(() => images.Ping(Files.Missing));
329280

330-
Assert.Contains("error/blob.c/OpenBlob", exception.Message);
281+
Assert.Contains("error/blob.c/OpenBlob", exception.Message);
282+
}
331283
}
332284

333285
[Fact]
@@ -366,13 +318,10 @@ public class WithStream
366318
[Fact]
367319
public void ShouldThrowExceptionWhenStreamIsNull()
368320
{
369-
Assert.Throws<ArgumentNullException>("stream", () =>
321+
using (var images = new MagickImageCollection())
370322
{
371-
using (var images = new MagickImageCollection())
372-
{
373-
images.Ping((Stream)null);
374-
}
375-
});
323+
Assert.Throws<ArgumentNullException>("stream", () => images.Ping((Stream)null));
324+
}
376325
}
377326

378327
[Fact]

0 commit comments

Comments
 (0)