From b5a6420ff7b5477ab0f014ace08278ba5fa23a59 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 5 Mar 2021 16:36:51 +0000 Subject: [PATCH] Check if test file exists before proceeding with test. --- .idea/.idea.Aaru/.idea/indexLayout.xml | 5 --- Aaru.Tests/Filesystems/FilesystemTest.cs | 31 ++++++++++++++++-- Aaru.Tests/Images/BlockMediaImageTest.cs | 23 +++++++++++-- Aaru.Tests/Images/OpticalMediaImageTest.cs | 23 +++++++++++-- Aaru.Tests/Images/TapeMediaImageTest.cs | 34 ++++++++++++++++++-- Aaru.Tests/Partitions/PartitionSchemeTest.cs | 9 ++++++ 6 files changed, 111 insertions(+), 14 deletions(-) diff --git a/.idea/.idea.Aaru/.idea/indexLayout.xml b/.idea/.idea.Aaru/.idea/indexLayout.xml index b69b747d3..7b08163ce 100644 --- a/.idea/.idea.Aaru/.idea/indexLayout.xml +++ b/.idea/.idea.Aaru/.idea/indexLayout.xml @@ -5,9 +5,4 @@ - - - - - \ No newline at end of file diff --git a/Aaru.Tests/Filesystems/FilesystemTest.cs b/Aaru.Tests/Filesystems/FilesystemTest.cs index 7095db3aa..8a52c69c6 100644 --- a/Aaru.Tests/Filesystems/FilesystemTest.cs +++ b/Aaru.Tests/Filesystems/FilesystemTest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; using Aaru.Core; @@ -30,7 +31,16 @@ namespace Aaru.Tests.Filesystems { foreach(FileSystemTest test in Tests) { - string testFile = test.TestFile; + string testFile = test.TestFile; + + bool exists = File.Exists(testFile); + Assert.True(exists, $"{testFile} not found"); + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // It arrives here... + if(!exists) + continue; + var filtersList = new FiltersList(); IFilter inputFilter = filtersList.GetFilter(testFile); @@ -97,7 +107,16 @@ namespace Aaru.Tests.Filesystems { foreach(FileSystemTest test in Tests) { - string testFile = test.TestFile; + string testFile = test.TestFile; + + bool exists = File.Exists(testFile); + Assert.True(exists, $"{testFile} not found"); + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // It arrives here... + if(!exists) + continue; + var filtersList = new FiltersList(); IFilter inputFilter = filtersList.GetFilter(testFile); @@ -129,6 +148,14 @@ namespace Aaru.Tests.Filesystems bool found = false; var partition = new Partition(); + bool exists = File.Exists(testFile); + Assert.True(exists, $"{testFile} not found"); + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // It arrives here... + if(!exists) + continue; + var filtersList = new FiltersList(); IFilter inputFilter = filtersList.GetFilter(testFile); diff --git a/Aaru.Tests/Images/BlockMediaImageTest.cs b/Aaru.Tests/Images/BlockMediaImageTest.cs index 61f80fac8..aadc51841 100644 --- a/Aaru.Tests/Images/BlockMediaImageTest.cs +++ b/Aaru.Tests/Images/BlockMediaImageTest.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using Aaru.Checksums; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; @@ -22,7 +23,16 @@ namespace Aaru.Tests.Images { foreach(BlockImageTestExpected test in Tests) { - string testFile = test.TestFile; + string testFile = test.TestFile; + + bool exists = File.Exists(testFile); + Assert.True(exists, $"{testFile} not found"); + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // It arrives here... + if(!exists) + continue; + var filtersList = new FiltersList(); IFilter filter = filtersList.GetFilter(testFile); filter.Open(testFile); @@ -58,7 +68,16 @@ namespace Aaru.Tests.Images { foreach(BlockImageTestExpected test in Tests) { - string testFile = test.TestFile; + string testFile = test.TestFile; + + bool exists = File.Exists(testFile); + Assert.True(exists, $"{testFile} not found"); + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // It arrives here... + if(!exists) + continue; + var filtersList = new FiltersList(); IFilter filter = filtersList.GetFilter(testFile); filter.Open(testFile); diff --git a/Aaru.Tests/Images/OpticalMediaImageTest.cs b/Aaru.Tests/Images/OpticalMediaImageTest.cs index 7c1dd47f4..eb49268b4 100644 --- a/Aaru.Tests/Images/OpticalMediaImageTest.cs +++ b/Aaru.Tests/Images/OpticalMediaImageTest.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Linq; using System.Threading.Tasks; using Aaru.Checksums; @@ -26,7 +27,16 @@ namespace Aaru.Tests.Images { foreach(OpticalImageTestExpected test in Tests) { - string testFile = test.TestFile; + string testFile = test.TestFile; + + bool exists = File.Exists(testFile); + Assert.True(exists, $"{testFile} not found"); + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // It arrives here... + if(!exists) + continue; + var filtersList = new FiltersList(); IFilter filter = filtersList.GetFilter(testFile); filter.Open(testFile); @@ -97,7 +107,16 @@ namespace Aaru.Tests.Images { Parallel.For(0L, Tests.Length, (i, state) => { - string testFile = Tests[i].TestFile; + string testFile = Tests[i].TestFile; + + bool exists = File.Exists(testFile); + Assert.True(exists, $"{testFile} not found"); + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // It arrives here... + if(!exists) + return; + var filtersList = new FiltersList(); IFilter filter = filtersList.GetFilter(testFile); filter.Open(testFile); diff --git a/Aaru.Tests/Images/TapeMediaImageTest.cs b/Aaru.Tests/Images/TapeMediaImageTest.cs index f41d4ead6..258439387 100644 --- a/Aaru.Tests/Images/TapeMediaImageTest.cs +++ b/Aaru.Tests/Images/TapeMediaImageTest.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using Aaru.Checksums; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; @@ -24,7 +25,16 @@ namespace Aaru.Tests.Images { foreach(TapeImageTestExpected test in Tests) { - string testFile = test.TestFile; + string testFile = test.TestFile; + + bool exists = File.Exists(testFile); + Assert.True(exists, $"{testFile} not found"); + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // It arrives here... + if(!exists) + continue; + var filtersList = new FiltersList(); IFilter filter = filtersList.GetFilter(testFile); filter.Open(testFile); @@ -63,7 +73,16 @@ namespace Aaru.Tests.Images { foreach(TapeImageTestExpected test in Tests) { - string testFile = test.TestFile; + string testFile = test.TestFile; + + bool exists = File.Exists(testFile); + Assert.True(exists, $"{testFile} not found"); + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // It arrives here... + if(!exists) + continue; + var filtersList = new FiltersList(); IFilter filter = filtersList.GetFilter(testFile); filter.Open(testFile); @@ -99,7 +118,16 @@ namespace Aaru.Tests.Images { foreach(TapeImageTestExpected test in Tests) { - string testFile = test.TestFile; + string testFile = test.TestFile; + + bool exists = File.Exists(testFile); + Assert.True(exists, $"{testFile} not found"); + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // It arrives here... + if(!exists) + continue; + var filtersList = new FiltersList(); IFilter filter = filtersList.GetFilter(testFile); filter.Open(testFile); diff --git a/Aaru.Tests/Partitions/PartitionSchemeTest.cs b/Aaru.Tests/Partitions/PartitionSchemeTest.cs index 33e102bb5..0af6dc7d9 100644 --- a/Aaru.Tests/Partitions/PartitionSchemeTest.cs +++ b/Aaru.Tests/Partitions/PartitionSchemeTest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; using Aaru.Core; @@ -21,6 +22,14 @@ namespace Aaru.Tests.Partitions string testFile = test.TestFile; Environment.CurrentDirectory = DataFolder; + bool exists = File.Exists(testFile); + Assert.True(exists, $"{testFile} not found"); + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // It arrives here... + if(!exists) + continue; + var filtersList = new FiltersList(); IFilter inputFilter = filtersList.GetFilter(testFile);