예제 #1
0
        public static void DoNewIgnoringExceptions_Returns_Null_WithIgnoredException2()
        {
            var result = IgnoreExceptionsHelper.DoConstructorIgnoringExceptions <Uri>(
                new[] { typeof(UriFormatException) },
                "junk uri");

            Assert.That(result, Is.Null);
        }
예제 #2
0
        public static void DoNewIgnoringExceptions_Returns_Null_WithIgnoredException1()
        {
            var result = IgnoreExceptionsHelper.DoConstructorIgnoringExceptions <ExampleClass>(
                new[] { typeof(ArgumentException) },
                typeof(ArgumentException));

            Assert.That(result, Is.Null);
        }
예제 #3
0
 public static void DoNewIgnoringExceptions_Throws_WithNonIgnoredException2()
 {
     Assert.That(
         () => IgnoreExceptionsHelper.DoConstructorIgnoringExceptions <Uri>(
             new[] { typeof(ArgumentException) },
             "Junk Uri"),
         Throws.TypeOf <UriFormatException>()
         );
 }
예제 #4
0
 public static void DoNewIgnoringExceptions_Throws_WithNonIgnoredException1()
 {
     Assert.That(
         () => IgnoreExceptionsHelper.DoConstructorIgnoringExceptions <ExampleClass>(
             new[] { typeof(ArgumentException) },
             typeof(InvalidOperationException)),
         Throws.InvalidOperationException
         );
 }
예제 #5
0
        public static void DoNewIgnoringExceptions_Returns_Value_WithNoException2()
        {
            var result = IgnoreExceptionsHelper.DoConstructorIgnoringExceptions <Uri>(
                new[] { typeof(ArgumentException) },
                "http://www.google.com");

            Assert.That(result, Is.Not.Null);
            Assert.That(result.AbsoluteUri, Is.Not.Null);
            Assert.That(result.AbsoluteUri.Length, Is.GreaterThan(0));
        }
예제 #6
0
        public static void DoNewIgnoringExceptions_Returns_Value_WithNoException1()
        {
            var result = IgnoreExceptionsHelper.DoConstructorIgnoringExceptions <ExampleClass>(
                new[] { typeof(ArgumentException) },
                typeof(string));

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Value, Is.Not.Null);
            Assert.That(result.Value.Length, Is.GreaterThan(0));
        }
        /// <inheritdoc />
        public FileInfo GetItem(SourceInformation searchInformation)
        {
            Validators.AssertIsNotNull(searchInformation, nameof(searchInformation));
            searchInformation.AssertIsValid();
            searchInformation.AssertIsSourceType(SourceType.Filesystem);

            Logger.Trace("Entering");

            var output = IgnoreExceptionsHelper.DoConstructorIgnoringExceptions <FileInfo>(
                new[] { typeof(FileNotFoundException), typeof(DirectoryNotFoundException) },
                searchInformation.SourcePath
                );

            if (!output.Exists)
            {
                output = null;
            }

            return(output);
        }