lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [lucenenet] 04/13: Lucene.Net.TestFramework: Refactored Assert classes to utilize FileSupport.IsFileAlreadyExistsException(). Deleted Support/TestFramework/AssertCommon.cs.
Date Sat, 26 Oct 2019 18:51:59 GMT
This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit eecbcda0162e6dc0c8ec376858e80c5593616dea
Author: Shad Storhaug <shad@shadstorhaug.com>
AuthorDate: Fri Oct 25 19:02:09 2019 +0700

    Lucene.Net.TestFramework: Refactored Assert classes to utilize FileSupport.IsFileAlreadyExistsException().
Deleted Support/TestFramework/AssertCommon.cs.
---
 .../Support/TestFramework/Assert.cs                |  3 +-
 .../Support/TestFramework/Assert.cs                |  3 +-
 .../Support/TestFramework/Assert.cs                |  3 +-
 .../Support/TestFramework/AssertCommon.cs          | 41 ----------------------
 4 files changed, 6 insertions(+), 44 deletions(-)

diff --git a/src/Lucene.Net.TestFramework.MSTest/Support/TestFramework/Assert.cs b/src/Lucene.Net.TestFramework.MSTest/Support/TestFramework/Assert.cs
index ce14510..a0c688c 100644
--- a/src/Lucene.Net.TestFramework.MSTest/Support/TestFramework/Assert.cs
+++ b/src/Lucene.Net.TestFramework.MSTest/Support/TestFramework/Assert.cs
@@ -1,4 +1,5 @@
 using Lucene.Net.Support;
+using Lucene.Net.Support.IO;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -584,7 +585,7 @@ namespace Lucene.Net.TestFramework
             {
                 action();
             }
-            catch (Exception ex) when (!IsFileAlreadyExistsException(ex, filePath))
+            catch (Exception ex) when (!FileSupport.IsFileAlreadyExistsException(ex, filePath))
             {
                 exception = ex;
             }
diff --git a/src/Lucene.Net.TestFramework.NUnit/Support/TestFramework/Assert.cs b/src/Lucene.Net.TestFramework.NUnit/Support/TestFramework/Assert.cs
index ad0d733..42a1bed 100644
--- a/src/Lucene.Net.TestFramework.NUnit/Support/TestFramework/Assert.cs
+++ b/src/Lucene.Net.TestFramework.NUnit/Support/TestFramework/Assert.cs
@@ -1,4 +1,5 @@
 using Lucene.Net.Support;
+using Lucene.Net.Support.IO;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -562,7 +563,7 @@ namespace Lucene.Net.TestFramework
                 action();
                 throw new _NUnit.AssertionException($"{messagePrefix} <null>");
             }
-            catch (Exception ex) when (!IsFileAlreadyExistsException(ex, filePath))
+            catch (Exception ex) when (!FileSupport.IsFileAlreadyExistsException(ex, filePath))
             {
                 throw new _NUnit.AssertionException($"{messagePrefix} {ex.GetType().FullName}",
ex);
             }
diff --git a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/Assert.cs b/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/Assert.cs
index 49ffb16..e086675 100644
--- a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/Assert.cs
+++ b/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/Assert.cs
@@ -1,4 +1,5 @@
 using Lucene.Net.Support;
+using Lucene.Net.Support.IO;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -567,7 +568,7 @@ namespace Lucene.Net.TestFramework
             {
                 action();
             }
-            catch (Exception ex) when (!IsFileAlreadyExistsException(ex, filePath))
+            catch (Exception ex) when (!FileSupport.IsFileAlreadyExistsException(ex, filePath))
             {
                 exception = ex;
             }
diff --git a/src/Lucene.Net.TestFramework/Support/TestFramework/AssertCommon.cs b/src/Lucene.Net.TestFramework/Support/TestFramework/AssertCommon.cs
deleted file mode 100644
index c1c59bd..0000000
--- a/src/Lucene.Net.TestFramework/Support/TestFramework/AssertCommon.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using Lucene.Net.Util;
-using System;
-using System.IO;
-
-namespace Lucene.Net.TestFramework
-{
-    /*
-     * Licensed to the Apache Software Foundation (ASF) under one or more
-     * contributor license agreements.  See the NOTICE file distributed with
-     * this work for additional information regarding copyright ownership.
-     * The ASF licenses this file to You under the Apache License, Version 2.0
-     * (the "License"); you may not use this file except in compliance with
-     * the License.  You may obtain a copy of the License at
-     *
-     *     http://www.apache.org/licenses/LICENSE-2.0
-     *
-     * Unless required by applicable law or agreed to in writing, software
-     * distributed under the License is distributed on an "AS IS" BASIS,
-     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     * See the License for the specific language governing permissions and
-     * limitations under the License.
-     */
-
-    /// <summary>
-    /// Common assertion code
-    /// </summary>
-    internal partial class Assert
-    {
-        private const int WARN_WIN32_FILE_EXISTS = unchecked((int)0x80070050);
-
-        private static bool IsFileAlreadyExistsException(Exception ex, string filePath)
-        {
-            if (!typeof(IOException).Equals(ex))
-                return false;
-            else if (Constants.WINDOWS)
-                return ex.HResult == WARN_WIN32_FILE_EXISTS;
-            else
-                return File.Exists(filePath);
-        }
-    }
-}


Mime
View raw message