Skip to content

Commit 9d79a34

Browse files
committed
Upgrade ExpectedException to nunit3.
1 parent 8f8ae9a commit 9d79a34

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

ICSharpCode.SharpZipLib.Tests/Zip/ZipTests.cs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,6 @@ public void UnsupportedCompressionMethod()
13501350
/// </summary>
13511351
[Test]
13521352
[Category("Zip")]
1353-
//[ExpectedException(typeof(ZipException))]
13541353
public void InvalidPasswordSeekable()
13551354
{
13561355
byte[] originalData = null;
@@ -1367,13 +1366,16 @@ public void InvalidPasswordSeekable()
13671366

13681367
ZipEntry entry2 = inStream.GetNextEntry();
13691368

1370-
while (true) {
1371-
int numRead = inStream.Read(buf2, pos, buf2.Length);
1372-
if (numRead <= 0) {
1373-
break;
1369+
Assert.Throws<ZipException>(() =>
1370+
{
1371+
while (true) {
1372+
int numRead = inStream.Read(buf2, pos, buf2.Length);
1373+
if (numRead <= 0) {
1374+
break;
1375+
}
1376+
pos += numRead;
13741377
}
1375-
pos += numRead;
1376-
}
1378+
});
13771379
}
13781380

13791381
/// <summary>
@@ -1413,7 +1415,6 @@ public void ExerciseGetNextEntry()
14131415
/// </summary>
14141416
[Test]
14151417
[Category("Zip")]
1416-
//[ExpectedException(typeof(ZipException))]
14171418
public void InvalidPasswordNonSeekable()
14181419
{
14191420
byte[] originalData = null;
@@ -1430,13 +1431,16 @@ public void InvalidPasswordNonSeekable()
14301431

14311432
ZipEntry entry2 = inStream.GetNextEntry();
14321433

1433-
while (true) {
1434-
int numRead = inStream.Read(buf2, pos, buf2.Length);
1435-
if (numRead <= 0) {
1436-
break;
1434+
Assert.Throws<ZipException>(() =>
1435+
{
1436+
while (true) {
1437+
int numRead = inStream.Read(buf2, pos, buf2.Length);
1438+
if (numRead <= 0) {
1439+
break;
1440+
}
1441+
pos += numRead;
14371442
}
1438-
pos += numRead;
1439-
}
1443+
});
14401444
}
14411445

14421446
/// <summary>
@@ -2680,19 +2684,21 @@ public void Encryption()
26802684

26812685
[Test]
26822686
[Category("Zip")]
2683-
//[ExpectedException(typeof(DirectoryNotFoundException))]
26842687
public void CreateExceptions()
26852688
{
26862689
var fastZip = new FastZip();
26872690
string tempFilePath = GetTempFilePath();
26882691
Assert.IsNotNull(tempFilePath, "No permission to execute this test?");
26892692

2690-
string addFile = Path.Combine(tempFilePath, "test.zip");
2691-
try {
2692-
fastZip.CreateZip(addFile, @"z:\doesnt exist", false, null);
2693-
} finally {
2694-
File.Delete(addFile);
2695-
}
2693+
Assert.Throws<DirectoryNotFoundException>(() =>
2694+
{
2695+
string addFile = Path.Combine(tempFilePath, "test.zip");
2696+
try {
2697+
fastZip.CreateZip(addFile, @"z:\doesnt exist", false, null);
2698+
} finally {
2699+
File.Delete(addFile);
2700+
}
2701+
});
26962702
}
26972703

26982704
[Test]

0 commit comments

Comments
 (0)