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 4c65db129363ac7700b3ce960308a1ce287dfdce Author: Shad Storhaug <[email protected]> AuthorDate: Wed Dec 22 19:12:07 2021 +0700 Lucene.Net.TestFramework: Removed files and folders for Lucene.Net.TestFramework.NUnit, Lucene.Net.TestFramework.MSTest, and Lucene.Net.TestFramework.xUnit and moved NUnit Assert class into Lucene.Net.TestFramework project. --- build/Dependencies.props | 4 - ...ucene.Net.TestFramework.MSTest.csproj.nosupport | 95 --- .../Properties/AssemblyInfo.cs | 50 -- .../Support/TestFramework/Assert.cs | 669 --------------------- ...Lucene.Net.TestFramework.NUnit.csproj.nosupport | 92 --- .../Properties/AssemblyInfo.cs | 82 --- ...Lucene.Net.TestFramework.xUnit.csproj.nosupport | 92 --- .../Properties/AssemblyInfo.cs | 50 -- .../Support/TestFramework/Assert.cs | 664 -------------------- .../Support/TestFramework/BeforeAfterClass.cs | 67 --- .../Support/TestFramework/SkipTestException.cs | 60 -- .../TestFramework/SkippableFactAttribute.cs | 31 - .../XunitExtensions/SkippableFactDiscoverer.cs | 39 -- .../XunitExtensions/SkippableFactMessageBus.cs | 55 -- .../XunitExtensions/SkippableFactTestCase.cs | 52 -- .../Lucene.Net.TestFramework.csproj | 4 - .../PortingWork-ReadMe.txt | 47 -- .../Support/TestFramework/Assert.cs | 2 +- src/Lucene.Net/Lucene.Net.csproj | 3 - 19 files changed, 1 insertion(+), 2157 deletions(-) diff --git a/build/Dependencies.props b/build/Dependencies.props index 90c8ce1..eda7bd0 100644 --- a/build/Dependencies.props +++ b/build/Dependencies.props @@ -63,8 +63,6 @@ <MorfologikFsaPackageVersion>2.1.7-beta-0004</MorfologikFsaPackageVersion> <MorfologikPolishPackageVersion>$(MorfologikFsaPackageVersion)</MorfologikPolishPackageVersion> <MorfologikStemmingPackageVersion>$(MorfologikFsaPackageVersion)</MorfologikStemmingPackageVersion> - <MSTestTestFrameworkPackageVersion>2.0.0</MSTestTestFrameworkPackageVersion> - <MSTestTestAdapterPackageVersion>$(MSTestTestFrameworkPackageVersion)</MSTestTestAdapterPackageVersion> <NETStandardLibrary20PackageVersion>2.0.3</NETStandardLibrary20PackageVersion> <NewtonsoftJsonPackageVersion>10.0.1</NewtonsoftJsonPackageVersion> <NUnit3TestAdapterPackageVersion>3.17.0</NUnit3TestAdapterPackageVersion> @@ -83,7 +81,5 @@ <SystemTextEncodingCodePagesPackageVersion>4.3.0</SystemTextEncodingCodePagesPackageVersion> <SystemTextEncodingCodePagesPackageVersion Condition=" '$(TargetFramework)' == 'net461' ">5.0.0</SystemTextEncodingCodePagesPackageVersion> <TimeZoneConverterPackageVersion>3.5.0</TimeZoneConverterPackageVersion> - <XUnitPackageVersion>2.3.1</XUnitPackageVersion> - <XUnitRunnerVisualStudioPackageVersion>$(XUnitPackageVersion)</XUnitRunnerVisualStudioPackageVersion> </PropertyGroup> </Project> \ No newline at end of file diff --git a/src/Lucene.Net.TestFramework.MSTest/Lucene.Net.TestFramework.MSTest.csproj.nosupport b/src/Lucene.Net.TestFramework.MSTest/Lucene.Net.TestFramework.MSTest.csproj.nosupport deleted file mode 100644 index fc2bc90..0000000 --- a/src/Lucene.Net.TestFramework.MSTest/Lucene.Net.TestFramework.MSTest.csproj.nosupport +++ /dev/null @@ -1,95 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - 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. - ---> -<Project Sdk="Microsoft.NET.Sdk"> - - <Import Project="$(SolutionDir)build/NuGet.props" /> - - <PropertyGroup> - <TargetFrameworks>netstandard2.0;netstandard1.6</TargetFrameworks> - <TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('Windows'))">$(TargetFrameworks);net45</TargetFrameworks> - <PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.6' ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback> - - <AssemblyTitle>Lucene.Net.TestFramework.MSTest</AssemblyTitle> - <RootNamespace>Lucene.Net</RootNamespace> - <Description>Framework for testing third-party code that uses the Lucene.Net API using MSTest.</Description> - <PackageTags>$(PackageTags);testframework;test;framework;mstest</PackageTags> - <DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile> - <NoWarn>$(NoWarn);1591;1573</NoWarn> - - <DefineConstants>$(DefineConstants);TESTFRAMEWORK_MSTEST</DefineConstants> - - <!-- LUCENENET: Not distributed because of incomplete support (ClassInitialize/ClassCleanup don't support inheritance, no reasonable way to run one class at a time) --> - <IsPackable>false</IsPackable> - </PropertyGroup> - - <ItemGroup> - <Compile Include="..\Lucene.Net.TestFramework\**\*.cs" /> - <Compile Remove="..\Lucene.Net.TestFramework\obj\**\*;..\Lucene.Net.TestFramework\bin\**\*" /> - <Compile Remove="..\Lucene.Net.TestFramework\Properties\*.cs" /> - </ItemGroup> - - <ItemGroup> - <None Remove="..\Lucene.Net.TestFramework\Util\europarl.lines.txt.gz" /> - <EmbeddedResource Include="..\Lucene.Net.TestFramework\Util\europarl.lines.txt.gz" Link="Util\europarl.lines.txt.gz" /> - <None Include="..\Lucene.Net.TestFramework\*.txt" /> - </ItemGroup> - - <ItemGroup> - <ProjectReference Include="..\Lucene.Net.Analysis.Common\Lucene.Net.Analysis.Common.csproj" /> - <ProjectReference Include="..\Lucene.Net.Codecs\Lucene.Net.Codecs.csproj" /> - </ItemGroup> - - <ItemGroup> - <PackageReference Include="MSTest.TestFramework" Version="$(MSTestTestFrameworkPackageVersion)" /> - </ItemGroup> - - <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> - <DefineConstants>$(DefineConstants);NETSTANDARD;FEATURE_CONCURRENTMERGESCHEDULER;FEATURE_SERIALIZABLE</DefineConstants> - <DebugType>portable</DebugType> - </PropertyGroup> - - <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' "> - <PackageReference Include="System.Diagnostics.StackTrace" Version="$(SystemDiagnosticsStackTracePackageVersion)" /> - <PackageReference Include="System.Diagnostics.TraceSource" Version="$(SystemDiagnosticsTraceSourcePackageVersion)" /> - <PackageReference Include="System.Net.Primitives" Version="$(SystemNetPrimitivesPackageVersion)" /> - <PackageReference Include="System.Threading.Thread" Version="$(SystemThreadingThreadPackageVersion)" /> - </ItemGroup> - - <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' "> - <DefineConstants>$(DefineConstants);NETSTANDARD;FEATURE_STACKTRACE</DefineConstants> - <DebugType>portable</DebugType> - </PropertyGroup> - - <PropertyGroup Condition=" '$(TargetFramework)' == 'net45' "> - <DefineConstants>$(DefineConstants);FEATURE_CONCURRENTMERGESCHEDULER;FEATURE_SERIALIZABLE;FEATURE_SERIALIZABLE_EXCEPTIONS</DefineConstants> - <DebugType>full</DebugType> - </PropertyGroup> - - <ItemGroup Condition=" '$(TargetFramework)' == 'net45' "> - <Reference Include="System.IO.Compression" /> - <Reference Include="System.Numerics" /> - <Reference Include="System.ServiceModel" /> - <Reference Include="System" /> - <Reference Include="Microsoft.CSharp" /> - </ItemGroup> - -</Project> diff --git a/src/Lucene.Net.TestFramework.MSTest/Properties/AssemblyInfo.cs b/src/Lucene.Net.TestFramework.MSTest/Properties/AssemblyInfo.cs deleted file mode 100644 index 76e6e1b..0000000 --- a/src/Lucene.Net.TestFramework.MSTest/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * 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. - * -*/ - -using Lucene.Net.Support; -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyDefaultAlias("Lucene.Net.TestFramework.MSTest")] -[assembly: AssemblyCulture("")] - -[assembly: CLSCompliant(true)] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5f36e3cf-82ac-4d97-af1a-6dabe60e9180")] - -// We need InternalsVisibleTo in order to prevent making everything public just for the sake of testing. -// This has broad implications, though because many methods are marked "protected internal", which means other assemblies -// must update overridden methods to match. -// Note that some of the APIs we use to test Lucene.Net are internal because they are only meant to -// make porting tests from Java easier. This means that every Lucene.Net test project requires -// InternalsVisibleTo, now and in the future to keep these APIs from public view. -[assembly: InternalsVisibleTo("Lucene.Net.Tests.TestFramework.MSTest, PublicKey=" + AssemblyKeys.PublicKey)] diff --git a/src/Lucene.Net.TestFramework.MSTest/Support/TestFramework/Assert.cs b/src/Lucene.Net.TestFramework.MSTest/Support/TestFramework/Assert.cs deleted file mode 100644 index 5570ff3..0000000 --- a/src/Lucene.Net.TestFramework.MSTest/Support/TestFramework/Assert.cs +++ /dev/null @@ -1,669 +0,0 @@ -using Lucene.Net.Support; -using Lucene.Net.Support.IO; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using MSTest = Microsoft.VisualStudio.TestTools.UnitTesting; - -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> - /// Facade for MSTest Assertions - /// </summary> - internal partial class Assert - { - // - // Summary: - // We don't actually want any instances of this object, but some people like to - // inherit from it to add other static methods. Hence, the protected constructor - // disallows any instances of this object. - protected Assert() - { } - - // - // Summary: - // Verifies that two objects are equal. Two objects are considered equal if both - // are null, or if both have the same value. NUnit has special semantics for some - // object types. If they are not equal an NUnit.Framework.AssertionException is - // thrown. - // - // Parameters: - // expected: - // The value that is expected - // - // actual: - // The actual value - public static void AreEqual(object expected, object actual) - { - MSTest.Assert.AreEqual(expected, actual); - } - // - // Summary: - // Verifies that two objects are equal. Two objects are considered equal if both - // are null, or if both have the same value. NUnit has special semantics for some - // object types. If they are not equal an NUnit.Framework.AssertionException is - // thrown. - // - // Parameters: - // expected: - // The value that is expected - // - // actual: - // The actual value - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void AreEqual(object expected, object actual, string message, params object[] args) - { - MSTest.Assert.AreEqual(expected, actual, message, args); - } - // - // Summary: - // Verifies that two objects are equal. Two objects are considered equal if both - // are null, or if both have the same value. NUnit has special semantics for some - // object types. If they are not equal an NUnit.Framework.AssertionException is - // thrown. - // - // Parameters: - // expected: - // The value that is expected - // - // actual: - // The actual value - public static void AreEqual(bool expected, bool actual) - { - MSTest.Assert.IsTrue(expected.Equals(actual)); - } - // - // Summary: - // Verifies that two objects are equal. Two objects are considered equal if both - // are null, or if both have the same value. NUnit has special semantics for some - // object types. If they are not equal an NUnit.Framework.AssertionException is - // thrown. - // - // Parameters: - // expected: - // The value that is expected - // - // actual: - // The actual value - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void AreEqual(bool expected, bool actual, string message, params object[] args) - { - MSTest.Assert.IsTrue(expected.Equals(actual), message, args); - } - // - // Summary: - // Verifies that two doubles are equal considering a delta. If the expected value - // is infinity then the delta value is ignored. If they are not equal then an NUnit.Framework.AssertionException - // is thrown. - // - // Parameters: - // expected: - // The expected value - // - // actual: - // The actual value - // - // delta: - // The maximum acceptable difference between the the expected and the actual - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void AreEqual(double expected, double actual, double delta, string message, params object[] args) - { - MSTest.Assert.AreEqual(expected, actual, delta, message, args); - } - // - // Summary: - // Verifies that two doubles are equal considering a delta. If the expected value - // is infinity then the delta value is ignored. If they are not equal then an NUnit.Framework.AssertionException - // is thrown. - // - // Parameters: - // expected: - // The expected value - // - // actual: - // The actual value - // - // delta: - // The maximum acceptable difference between the the expected and the actual - public static void AreEqual(double expected, double actual, double delta) - { - MSTest.Assert.AreEqual(expected, actual, delta); - } - - // From CollectionAssert - public static void AreEqual<T>(T[] expected, T[] actual) - { - MSTest.CollectionAssert.AreEqual(expected, actual); - } - - // From CollectionAssert - public static void AreEqual<T>(T[] expected, T[] actual, string message, params object[] args) - { - MSTest.CollectionAssert.AreEqual(expected, actual, message, args); - } - - public static void AreEqual<T, S>(IDictionary<T, S> expected, IDictionary<T, S> actual) - { - AreEqual(expected.Count, actual.Count); - foreach (var key in expected.Keys) - { - AreEqual(expected[key], actual[key]); - } - } - - // From CollectionAssert - public static void AreEqual(ICollection expected, ICollection actual) - { - MSTest.CollectionAssert.AreEqual(expected, actual); - } - - // From CollectionAssert - public static void AreEqual(ICollection expected, ICollection actual, string message, params object[] args) - { - MSTest.CollectionAssert.AreEqual(expected, actual, message, args); - } - - - // - // Summary: - // Verifies that two objects are not equal. Two objects are considered equal if - // both are null, or if both have the same value. NUnit has special semantics for - // some object types. If they are equal an NUnit.Framework.AssertionException is - // thrown. - // - // Parameters: - // expected: - // The value that is expected - // - // actual: - // The actual value - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void AreNotEqual(object expected, object actual, string message, params object[] args) - { - MSTest.Assert.AreNotEqual(expected, actual, message, args); - } - // - // Summary: - // Verifies that two objects are not equal. Two objects are considered equal if - // both are null, or if both have the same value. NUnit has special semantics for - // some object types. If they are equal an NUnit.Framework.AssertionException is - // thrown. - // - // Parameters: - // expected: - // The value that is expected - // - // actual: - // The actual value - public static void AreNotEqual(object expected, object actual) - { - MSTest.Assert.AreNotEqual(expected, actual); - } - // - // Summary: - // Asserts that two objects do not refer to the same object. If they are the same - // an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // expected: - // The expected object - // - // actual: - // The actual object - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void AreNotSame(object expected, object actual, string message, params object[] args) - { - MSTest.Assert.AreNotSame(expected, actual, message, args); - } - // - // Summary: - // Asserts that two objects do not refer to the same object. If they are the same - // an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // expected: - // The expected object - // - // actual: - // The actual object - public static void AreNotSame(object expected, object actual) - { - MSTest.Assert.AreNotSame(expected, actual); - } - // - // Summary: - // Asserts that two objects refer to the same object. If they are not the same an - // NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // expected: - // The expected object - // - // actual: - // The actual object - public static void AreSame(object expected, object actual) - { - MSTest.Assert.AreSame(expected, actual); - } - // - // Summary: - // Asserts that two objects refer to the same object. If they are not the same an - // NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // expected: - // The expected object - // - // actual: - // The actual object - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void AreSame(object expected, object actual, string message, params object[] args) - { - MSTest.Assert.AreSame(expected, actual, message, args); - } - - public static void Fail(string message, params object[] args) - { - MSTest.Assert.Fail(message, args); - } - // - // Summary: - // Throws an NUnit.Framework.AssertionException. This is used by the other Assert - // functions. - public static void Fail() - { - MSTest.Assert.Fail(); - } - // - // Summary: - // Throws an NUnit.Framework.AssertionException with the message that is passed - // in. This is used by the other Assert functions. - // - // Parameters: - // message: - // The message to initialize the NUnit.Framework.AssertionException with. - public static void Fail(string message) - { - MSTest.Assert.Fail(message); - } - - // - // Summary: - // Asserts that a condition is false. If the condition is true the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void False(bool condition, string message, params object[] args) - { - MSTest.Assert.IsFalse(condition, message, args); - } - // - // Summary: - // Asserts that a condition is false. If the condition is true the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - public static void False(bool condition) - { - MSTest.Assert.IsFalse(condition); - } - - // - // Summary: - // Asserts that a condition is false. If the condition is true the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - public static void IsFalse(bool condition) - { - MSTest.Assert.IsFalse(condition); - } - - // - // Summary: - // Asserts that a condition is false. If the condition is true the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void IsFalse(bool condition, string message, params object[] args) - { - MSTest.Assert.IsFalse(condition, message, args); - } - - // - // Summary: - // Verifies that the object that is passed in is not equal to null If the object - // is null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void IsNotNull(object anObject, string message, params object[] args) - { - MSTest.Assert.IsNotNull(anObject, message, args); - } - // - // Summary: - // Verifies that the object that is passed in is not equal to null If the object - // is null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - public static void IsNotNull(object anObject) - { - MSTest.Assert.IsNotNull(anObject); - } - // - // Summary: - // Verifies that the object that is passed in is equal to null If the object is - // not null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - public static void IsNull(object anObject) - { - MSTest.Assert.IsNull(anObject); - } - // - // Summary: - // Verifies that the object that is passed in is equal to null If the object is - // not null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void IsNull(object anObject, string message, params object[] args) - { - MSTest.Assert.IsNull(anObject, message, args); - } - - // - // Summary: - // Asserts that a condition is true. If the condition is false the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void IsTrue(bool condition, string message, params object[] args) - { - MSTest.Assert.IsTrue(condition, message, args); - } - - // - // Summary: - // Asserts that a condition is true. If the condition is false the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - public static void IsTrue(bool condition) - { - MSTest.Assert.IsTrue(condition); - } - - // - // Summary: - // Verifies that the object that is passed in is not equal to null If the object - // is null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - public static void NotNull(object anObject) - { - MSTest.Assert.IsNotNull(anObject); - } - // - // Summary: - // Verifies that the object that is passed in is not equal to null If the object - // is null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void NotNull(object anObject, string message, params object[] args) - { - MSTest.Assert.IsNotNull(anObject, message, args); - } - - // - // Summary: - // Verifies that the object that is passed in is equal to null If the object is - // not null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - // - // message: - // The message to display in case of failure - // - // args:void Null - // Array of objects to be used in formatting the message - public static void Null(object anObject, string message, params object[] args) - { - MSTest.Assert.IsNull(anObject, message, args); - } - // - // Summary: - // Verifies that the object that is passed in is equal to null If the object is - // not null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - public static void Null(object anObject) - { - MSTest.Assert.IsNull(anObject); - } - - // - // Summary: - // Asserts that a condition is true. If the condition is false the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void True(bool condition, string message, params object[] args) - { - MSTest.Assert.IsTrue(condition, message, args); - } - - // - // Summary: - // Asserts that a condition is true. If the condition is false the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - public static void True(bool condition) - { - MSTest.Assert.IsTrue(condition); - } - - - public static Exception Throws<TException>(Action action) - { - return Throws(typeof(TException), action); - } - - public static Exception Throws(Type expectedExceptionType, Action action) - { - if (expectedExceptionType == null) - throw new ArgumentNullException(nameof(expectedExceptionType)); - if (action == null) - throw new ArgumentNullException(nameof(action)); - - var messagePrefix = $"Expected: {expectedExceptionType.GetType().FullName}\nBut was:"; - Exception exception = null; - try - { - action(); - } - catch (Exception ex) when (!ex.GetType().Equals(expectedExceptionType)) - { - exception = ex; - } - catch (Exception ex) - { - return ex; // Success - } - string exString = exception == null ? "<null>" : exception.GetType().FullName; - MSTest.Assert.Fail($"{messagePrefix} {exString}"); - return null; - } - - public static Exception ThrowsFileAlreadyExistsException(string filePath, Action action) - { - var messagePrefix = $"Expected: IOException indicating file not found\nBut was:"; - Exception exception = null; - try - { - action(); - } - catch (Exception ex) when (!FileSupport.IsFileAlreadyExistsException(ex, filePath)) - { - exception = ex; - } - catch (Exception ex) - { - return ex; // Success - } - string exString = exception == null ? "<null>" : exception.GetType().FullName; - MSTest.Assert.Fail($"{messagePrefix} {exString}"); - return null; - } - - public static Exception ThrowsAnyOf<TException1, TException2>(Action action) - { - return ThrowsAnyOf(new Type[] { typeof(TException1), typeof(TException2) }, action); - } - - public static Exception ThrowsAnyOf<TException1, TException2, TException3>(Action action) - { - return ThrowsAnyOf(new Type[] { typeof(TException1), typeof(TException2), typeof(TException3) }, action); - } - - public static Exception ThrowsAnyOf(IEnumerable<Type> expectedExceptionTypes, Action action) - { - var messagePrefix = $"Expected one of: {Collections.ToString(expectedExceptionTypes.Select(ex => ex.FullName).ToArray())}\nBut was:"; - try - { - action(); - throw new MSTest.AssertFailedException($"{messagePrefix} <null>"); - } - catch (Exception ex) when (!expectedExceptionTypes.Contains(ex.GetType())) - { - throw new MSTest.AssertFailedException($"{messagePrefix} {ex.GetType().FullName}", ex); - } - catch (Exception ex) - { - return ex; // Success - } - } - } -} diff --git a/src/Lucene.Net.TestFramework.NUnit/Lucene.Net.TestFramework.NUnit.csproj.nosupport b/src/Lucene.Net.TestFramework.NUnit/Lucene.Net.TestFramework.NUnit.csproj.nosupport deleted file mode 100644 index b4946a3..0000000 --- a/src/Lucene.Net.TestFramework.NUnit/Lucene.Net.TestFramework.NUnit.csproj.nosupport +++ /dev/null @@ -1,92 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - 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. - ---> -<Project Sdk="Microsoft.NET.Sdk"> - - <Import Project="$(SolutionDir)build/NuGet.props" /> - - <PropertyGroup> - <TargetFrameworks>netstandard2.0;netstandard1.6</TargetFrameworks> - <TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('Windows'))">$(TargetFrameworks);net45</TargetFrameworks> - <PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.6' ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback> - - <AssemblyTitle>Lucene.Net.TestFramework.NUnit</AssemblyTitle> - <RootNamespace>Lucene.Net</RootNamespace> - <Description>Framework for testing third-party code that uses the Lucene.Net API using NUnit.</Description> - <PackageTags>$(PackageTags);testframework;test;framework;nunit</PackageTags> - <DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile> - <NoWarn>$(NoWarn);1591;1573</NoWarn> - - <DefineConstants>$(DefineConstants);TESTFRAMEWORK_NUNIT</DefineConstants> - </PropertyGroup> - - <ItemGroup> - <Compile Include="..\Lucene.Net.TestFramework\**\*.cs" /> - <Compile Remove="..\Lucene.Net.TestFramework\obj\**\*;..\Lucene.Net.TestFramework\bin\**\*" /> - <Compile Remove="..\Lucene.Net.TestFramework\Properties\*.cs" /> - </ItemGroup> - - <ItemGroup> - <None Remove="..\Lucene.Net.TestFramework\Util\europarl.lines.txt.gz" /> - <EmbeddedResource Include="..\Lucene.Net.TestFramework\Util\europarl.lines.txt.gz" Link="Util\europarl.lines.txt.gz" /> - <None Include="..\Lucene.Net.TestFramework\*.txt" /> - </ItemGroup> - - <ItemGroup> - <ProjectReference Include="..\Lucene.Net.Analysis.Common\Lucene.Net.Analysis.Common.csproj" /> - <ProjectReference Include="..\Lucene.Net.Codecs\Lucene.Net.Codecs.csproj" /> - </ItemGroup> - - <ItemGroup> - <PackageReference Include="NUnit" Version="$(NUnitPackageVersion)" /> - </ItemGroup> - - <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> - <DefineConstants>$(DefineConstants);NETSTANDARD;FEATURE_CONCURRENTMERGESCHEDULER;FEATURE_SERIALIZABLE</DefineConstants> - <DebugType>portable</DebugType> - </PropertyGroup> - - <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' "> - <PackageReference Include="System.Diagnostics.StackTrace" Version="$(SystemDiagnosticsStackTracePackageVersion)" /> - <PackageReference Include="System.Diagnostics.TraceSource" Version="$(SystemDiagnosticsTraceSourcePackageVersion)" /> - <PackageReference Include="System.Net.Primitives" Version="$(SystemNetPrimitivesPackageVersion)" /> - <PackageReference Include="System.Threading.Thread" Version="$(SystemThreadingThreadPackageVersion)" /> - </ItemGroup> - - <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' "> - <DefineConstants>$(DefineConstants);NETSTANDARD;FEATURE_STACKTRACE</DefineConstants> - <DebugType>portable</DebugType> - </PropertyGroup> - - <PropertyGroup Condition=" '$(TargetFramework)' == 'net45' "> - <DefineConstants>$(DefineConstants);FEATURE_CONCURRENTMERGESCHEDULER;FEATURE_SERIALIZABLE;FEATURE_SERIALIZABLE_EXCEPTIONS</DefineConstants> - <DebugType>full</DebugType> - </PropertyGroup> - - <ItemGroup Condition=" '$(TargetFramework)' == 'net45' "> - <Reference Include="System.IO.Compression" /> - <Reference Include="System.Numerics" /> - <Reference Include="System.ServiceModel" /> - <Reference Include="System" /> - <Reference Include="Microsoft.CSharp" /> - </ItemGroup> - -</Project> diff --git a/src/Lucene.Net.TestFramework.NUnit/Properties/AssemblyInfo.cs b/src/Lucene.Net.TestFramework.NUnit/Properties/AssemblyInfo.cs deleted file mode 100644 index 942dec1..0000000 --- a/src/Lucene.Net.TestFramework.NUnit/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * 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. - * -*/ - -using Lucene.Net.Support; -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyDefaultAlias("Lucene.Net.TestFramework.NUnit")] -[assembly: AssemblyCulture("")] - -[assembly: CLSCompliant(true)] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5f36e3cf-82ac-4d97-af1a-6dabe60e9180")] - -// We need InternalsVisibleTo in order to prevent making everything public just for the sake of testing. -// This has broad implications, though because many methods are marked "protected internal", which means other assemblies -// must update overridden methods to match. -// Note that some of the APIs we use to test Lucene.Net are internal because they are only meant to -// make porting tests from Java easier. This means that every Lucene.Net test project requires -// InternalsVisibleTo, now and in the future to keep these APIs from public view. -[assembly: InternalsVisibleTo("Lucene.Net.Tests._A-D, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests._E-I, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests._J-S, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests._T-U, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests._U-Z, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Analysis.Common, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Analysis.Kuromoji, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Analysis.Morfologik, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Analysis.OpenNLP, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Analysis.Phonetic, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Analysis.SmartCn, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Analysis.Stempel, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Benchmark, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Classification, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Cli, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Codecs, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Demo, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Expressions, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Facet, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Grouping, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Highlighter, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Join, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.ICU, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Memory, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Misc, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Queries, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.QueryParser, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Replicator, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Sandbox, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Spatial, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.Suggest, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.TestFramework, PublicKey=" + AssemblyKeys.PublicKey)] -[assembly: InternalsVisibleTo("Lucene.Net.Tests.TestFramework.NUnit, PublicKey=" + AssemblyKeys.PublicKey)] diff --git a/src/Lucene.Net.TestFramework.xUnit/Lucene.Net.TestFramework.xUnit.csproj.nosupport b/src/Lucene.Net.TestFramework.xUnit/Lucene.Net.TestFramework.xUnit.csproj.nosupport deleted file mode 100644 index 972f309..0000000 --- a/src/Lucene.Net.TestFramework.xUnit/Lucene.Net.TestFramework.xUnit.csproj.nosupport +++ /dev/null @@ -1,92 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - - 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. - ---> -<Project Sdk="Microsoft.NET.Sdk"> - - <Import Project="$(SolutionDir)build/NuGet.props" /> - - <PropertyGroup> - <TargetFrameworks>netstandard2.0;netstandard1.6</TargetFrameworks> - <TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('Windows'))">$(TargetFrameworks);net45</TargetFrameworks> - <PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.6' ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback> - - <AssemblyTitle>Lucene.Net.TestFramework.xUnit</AssemblyTitle> - <RootNamespace>Lucene.Net</RootNamespace> - <Description>Framework for testing third-party code that uses the Lucene.Net API using xUnit.</Description> - <PackageTags>$(PackageTags);testframework;test;framework;xunit</PackageTags> - <DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile> - <NoWarn>$(NoWarn);1591;1573</NoWarn> - - <DefineConstants>$(DefineConstants);TESTFRAMEWORK_XUNIT</DefineConstants> - </PropertyGroup> - - <ItemGroup> - <Compile Include="..\Lucene.Net.TestFramework\**\*.cs" /> - <Compile Remove="..\Lucene.Net.TestFramework\obj\**\*;..\Lucene.Net.TestFramework\bin\**\*" /> - <Compile Remove="..\Lucene.Net.TestFramework\Properties\*.cs" /> - </ItemGroup> - - <ItemGroup> - <None Remove="..\Lucene.Net.TestFramework\Util\europarl.lines.txt.gz" /> - <EmbeddedResource Include="..\Lucene.Net.TestFramework\Util\europarl.lines.txt.gz" Link="Util\europarl.lines.txt.gz" /> - <None Include="..\Lucene.Net.TestFramework\*.txt" /> - </ItemGroup> - - <ItemGroup> - <ProjectReference Include="..\Lucene.Net.Analysis.Common\Lucene.Net.Analysis.Common.csproj" /> - <ProjectReference Include="..\Lucene.Net.Codecs\Lucene.Net.Codecs.csproj" /> - </ItemGroup> - - <ItemGroup> - <PackageReference Include="xunit" Version="$(XUnitPackageVersion)" /> - </ItemGroup> - - <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> - <DefineConstants>$(DefineConstants);NETSTANDARD;FEATURE_CONCURRENTMERGESCHEDULER;FEATURE_SERIALIZABLE</DefineConstants> - <DebugType>portable</DebugType> - </PropertyGroup> - - <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' "> - <PackageReference Include="System.Diagnostics.StackTrace" Version="$(SystemDiagnosticsStackTracePackageVersion)" /> - <PackageReference Include="System.Diagnostics.TraceSource" Version="$(SystemDiagnosticsTraceSourcePackageVersion)" /> - <PackageReference Include="System.Net.Primitives" Version="$(SystemNetPrimitivesPackageVersion)" /> - <PackageReference Include="System.Threading.Thread" Version="$(SystemThreadingThreadPackageVersion)" /> - </ItemGroup> - - <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' "> - <DefineConstants>$(DefineConstants);NETSTANDARD;FEATURE_STACKTRACE</DefineConstants> - <DebugType>portable</DebugType> - </PropertyGroup> - - <PropertyGroup Condition=" '$(TargetFramework)' == 'net45' "> - <DefineConstants>$(DefineConstants);FEATURE_CONCURRENTMERGESCHEDULER;FEATURE_SERIALIZABLE;FEATURE_SERIALIZABLE_EXCEPTIONS</DefineConstants> - <DebugType>full</DebugType> - </PropertyGroup> - - <ItemGroup Condition=" '$(TargetFramework)' == 'net45' "> - <Reference Include="System.IO.Compression" /> - <Reference Include="System.Numerics" /> - <Reference Include="System.ServiceModel" /> - <Reference Include="System" /> - <Reference Include="Microsoft.CSharp" /> - </ItemGroup> - -</Project> diff --git a/src/Lucene.Net.TestFramework.xUnit/Properties/AssemblyInfo.cs b/src/Lucene.Net.TestFramework.xUnit/Properties/AssemblyInfo.cs deleted file mode 100644 index 4416c32..0000000 --- a/src/Lucene.Net.TestFramework.xUnit/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * 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. - * -*/ - -using Lucene.Net.Support; -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyDefaultAlias("Lucene.Net.TestFramework.xUnit")] -[assembly: AssemblyCulture("")] - -[assembly: CLSCompliant(true)] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5f36e3cf-82ac-4d97-af1a-6dabe60e9180")] - -// We need InternalsVisibleTo in order to prevent making everything public just for the sake of testing. -// This has broad implications, though because many methods are marked "protected internal", which means other assemblies -// must update overridden methods to match. -// Note that some of the APIs we use to test Lucene.Net are internal because they are only meant to -// make porting tests from Java easier. This means that every Lucene.Net test project requires -// InternalsVisibleTo, now and in the future to keep these APIs from public view. -[assembly: InternalsVisibleTo("Lucene.Net.Tests.TestFramework.xUnit, PublicKey=" + AssemblyKeys.PublicKey)] diff --git a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/Assert.cs b/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/Assert.cs deleted file mode 100644 index 51c00b9..0000000 --- a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/Assert.cs +++ /dev/null @@ -1,664 +0,0 @@ -using Lucene.Net.Support; -using Lucene.Net.Support.IO; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; - -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> - /// Facade for xUnit Assertions - /// </summary> - internal partial class Assert - { - // - // Summary: - // We don't actually want any instances of this object, but some people like to - // inherit from it to add other static methods. Hence, the protected constructor - // disallows any instances of this object. - protected Assert() - { } - - // - // Summary: - // Verifies that two objects are equal. Two objects are considered equal if both - // are null, or if both have the same value. NUnit has special semantics for some - // object types. If they are not equal an NUnit.Framework.AssertionException is - // thrown. - // - // Parameters: - // expected: - // The value that is expected - // - // actual: - // The actual value - public static void AreEqual(object expected, object actual) - { - Xunit.Assert.Equal(expected, actual); - } - // - // Summary: - // Verifies that two objects are equal. Two objects are considered equal if both - // are null, or if both have the same value. NUnit has special semantics for some - // object types. If they are not equal an NUnit.Framework.AssertionException is - // thrown. - // - // Parameters: - // expected: - // The value that is expected - // - // actual: - // The actual value - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void AreEqual(object expected, object actual, string message, params object[] args) - { - Xunit.Assert.True(object.Equals(expected, actual), FormatMessage(message, args)); - } - // - // Summary: - // Verifies that two objects are equal. Two objects are considered equal if both - // are null, or if both have the same value. NUnit has special semantics for some - // object types. If they are not equal an NUnit.Framework.AssertionException is - // thrown. - // - // Parameters: - // expected: - // The value that is expected - // - // actual: - // The actual value - public static void AreEqual(bool expected, bool actual) - { - Xunit.Assert.True(expected.Equals(actual)); - } - // - // Summary: - // Verifies that two objects are equal. Two objects are considered equal if both - // are null, or if both have the same value. NUnit has special semantics for some - // object types. If they are not equal an NUnit.Framework.AssertionException is - // thrown. - // - // Parameters: - // expected: - // The value that is expected - // - // actual: - // The actual value - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void AreEqual(bool expected, bool actual, string message, params object[] args) - { - Xunit.Assert.True(expected.Equals(actual), FormatMessage(message, args)); - } - // - // Summary: - // Verifies that two doubles are equal considering a delta. If the expected value - // is infinity then the delta value is ignored. If they are not equal then an NUnit.Framework.AssertionException - // is thrown. - // - // Parameters: - // expected: - // The expected value - // - // actual: - // The actual value - // - // delta: - // The maximum acceptable difference between the the expected and the actual - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void AreEqual(double expected, double actual, double delta, string message, params object[] args) - { - if (double.IsNaN(expected) || double.IsInfinity(expected)) - Xunit.Assert.True(expected.Equals(actual), string.Format(message, args)); - else - Xunit.Assert.True(expected - actual <= delta || actual - expected <= delta, FormatMessage(message, args)); - } - // - // Summary: - // Verifies that two doubles are equal considering a delta. If the expected value - // is infinity then the delta value is ignored. If they are not equal then an NUnit.Framework.AssertionException - // is thrown. - // - // Parameters: - // expected: - // The expected value - // - // actual: - // The actual value - // - // delta: - // The maximum acceptable difference between the the expected and the actual - public static void AreEqual(double expected, double actual, double delta) - { - if (double.IsNaN(expected) || double.IsInfinity(expected)) - Xunit.Assert.True(expected.Equals(actual)); - else - Xunit.Assert.True(expected - actual <= delta || actual - expected <= delta); - } - - // From CollectionAssert - public static void AreEqual<T>(T[] expected, T[] actual) - { - Xunit.Assert.Equal(expected, actual); - } - - // From CollectionAssert - public static void AreEqual<T>(T[] expected, T[] actual, string message, params object[] args) - { - Xunit.Assert.True(System.Array.Equals(expected, actual), FormatMessage(message, args)); - } - - public static void AreEqual<T, S>(IDictionary<T, S> expected, IDictionary<T, S> actual) - { - AreEqual(expected.Count, actual.Count); - foreach (var key in expected.Keys) - { - AreEqual(expected[key], actual[key]); - } - } - - // From CollectionAssert - public static void AreEqual(ICollection expected, ICollection actual) - { - Xunit.Assert.Equal(expected, actual); - } - - // From CollectionAssert - public static void AreEqual(ICollection expected, ICollection actual, string message, params object[] args) - { - Xunit.Assert.True(Collections.Equals(expected, actual), FormatMessage(message, args)); - } - - // - // Summary: - // Verifies that two objects are not equal. Two objects are considered equal if - // both are null, or if both have the same value. NUnit has special semantics for - // some object types. If they are equal an NUnit.Framework.AssertionException is - // thrown. - // - // Parameters: - // expected: - // The value that is expected - // - // actual: - // The actual value - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void AreNotEqual(object expected, object actual, string message, params object[] args) - { - Xunit.Assert.True(!Collections.Equals(expected, actual), FormatMessage(message, args)); - } - // - // Summary: - // Verifies that two objects are not equal. Two objects are considered equal if - // both are null, or if both have the same value. NUnit has special semantics for - // some object types. If they are equal an NUnit.Framework.AssertionException is - // thrown. - // - // Parameters: - // expected: - // The value that is expected - // - // actual: - // The actual value - public static void AreNotEqual(object expected, object actual) - { - Xunit.Assert.NotEqual(expected, actual); - } - // - // Summary: - // Asserts that two objects do not refer to the same object. If they are the same - // an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // expected: - // The expected object - // - // actual: - // The actual object - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void AreNotSame(object expected, object actual, string message, params object[] args) - { - Xunit.Assert.True(!object.ReferenceEquals(expected, actual), FormatMessage(message, args)); - } - // - // Summary: - // Asserts that two objects do not refer to the same object. If they are the same - // an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // expected: - // The expected object - // - // actual: - // The actual object - public static void AreNotSame(object expected, object actual) - { - Xunit.Assert.NotSame(expected, actual); - } - // - // Summary: - // Asserts that two objects refer to the same object. If they are not the same an - // NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // expected: - // The expected object - // - // actual: - // The actual object - public static void AreSame(object expected, object actual) - { - Xunit.Assert.Same(expected, actual); - } - // - // Summary: - // Asserts that two objects refer to the same object. If they are not the same an - // NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // expected: - // The expected object - // - // actual: - // The actual object - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void AreSame(object expected, object actual, string message, params object[] args) - { - Xunit.Assert.True(object.ReferenceEquals(expected, actual), FormatMessage(message, args)); - } - - public static void Fail(string message, params object[] args) - { - Xunit.Assert.True(false, FormatMessage(message, args)); - } - // - // Summary: - // Throws an NUnit.Framework.AssertionException. This is used by the other Assert - // functions. - public static void Fail() - { - Xunit.Assert.True(false); - } - // - // Summary: - // Throws an NUnit.Framework.AssertionException with the message that is passed - // in. This is used by the other Assert functions. - // - // Parameters: - // message: - // The message to initialize the NUnit.Framework.AssertionException with. - public static void Fail(string message) - { - Xunit.Assert.True(false, message); - } - - // - // Summary: - // Asserts that a condition is false. If the condition is true the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void False(bool condition, string message, params object[] args) - { - Xunit.Assert.False(condition, FormatMessage(message, args)); - } - // - // Summary: - // Asserts that a condition is false. If the condition is true the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - public static void False(bool condition) - { - Xunit.Assert.False(condition); - } - - // - // Summary: - // Asserts that a condition is false. If the condition is true the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - public static void IsFalse(bool condition) - { - Xunit.Assert.False(condition); - } - - // - // Summary: - // Asserts that a condition is false. If the condition is true the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void IsFalse(bool condition, string message, params object[] args) - { - Xunit.Assert.False(condition, FormatMessage(message, args)); - } - - // - // Summary: - // Verifies that the object that is passed in is not equal to null If the object - // is null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void IsNotNull(object anObject, string message, params object[] args) - { - Xunit.Assert.True(anObject != null, FormatMessage(message, args)); - } - // - // Summary: - // Verifies that the object that is passed in is not equal to null If the object - // is null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - public static void IsNotNull(object anObject) - { - Xunit.Assert.NotNull(anObject); - } - // - // Summary: - // Verifies that the object that is passed in is equal to null If the object is - // not null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - public static void IsNull(object anObject) - { - Xunit.Assert.Null(anObject); - } - // - // Summary: - // Verifies that the object that is passed in is equal to null If the object is - // not null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void IsNull(object anObject, string message, params object[] args) - { - Xunit.Assert.True(anObject == null, FormatMessage(message, args)); - } - - // - // Summary: - // Asserts that a condition is true. If the condition is false the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void IsTrue(bool condition, string message, params object[] args) - { - Xunit.Assert.True(condition, FormatMessage(message, args)); - } - - // - // Summary: - // Asserts that a condition is true. If the condition is false the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - public static void IsTrue(bool condition) - { - Xunit.Assert.True(condition); - } - - // - // Summary: - // Verifies that the object that is passed in is not equal to null If the object - // is null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - public static void NotNull(object anObject) - { - Xunit.Assert.NotNull(anObject); - } - // - // Summary: - // Verifies that the object that is passed in is not equal to null If the object - // is null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void NotNull(object anObject, string message, params object[] args) - { - Xunit.Assert.True(anObject != null, FormatMessage(message, args)); - } - - // - // Summary: - // Verifies that the object that is passed in is equal to null If the object is - // not null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - // - // message: - // The message to display in case of failure - // - // args:void Null - // Array of objects to be used in formatting the message - public static void Null(object anObject, string message, params object[] args) - { - Xunit.Assert.True(anObject == null, FormatMessage(message, args)); - } - // - // Summary: - // Verifies that the object that is passed in is equal to null If the object is - // not null then an NUnit.Framework.AssertionException is thrown. - // - // Parameters: - // anObject: - // The object that is to be tested - public static void Null(object anObject) - { - Xunit.Assert.Null(anObject); - } - - // - // Summary: - // Asserts that a condition is true. If the condition is false the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - // - // message: - // The message to display in case of failure - // - // args: - // Array of objects to be used in formatting the message - public static void True(bool condition, string message, params object[] args) - { - Xunit.Assert.True(condition, FormatMessage(message, args)); - } - - // - // Summary: - // Asserts that a condition is true. If the condition is false the method throws - // an NUnit.Framework.AssertionException. - // - // Parameters: - // condition: - // The evaluated condition - public static void True(bool condition) - { - Xunit.Assert.True(condition); - } - - - public static Exception Throws<TException>(Action action) - { - return Throws(typeof(TException), action); - } - - public static Exception Throws(Type expectedExceptionType, Action action) - { - return Xunit.Assert.Throws(expectedExceptionType, () => action()); - } - - public static Exception ThrowsFileAlreadyExistsException(string filePath, Action action) - { - var messagePrefix = $"Expected: IOException indicating file not found\nBut was:"; - Exception exception = null; - try - { - action(); - } - catch (Exception ex) when (!FileSupport.IsFileAlreadyExistsException(ex, filePath)) - { - exception = ex; - } - catch (Exception ex) - { - return ex; // Success - } - string exString = exception == null ? "<null>" : exception.GetType().FullName; - Xunit.Assert.False(true, $"{messagePrefix} {exString}"); - return null; - } - - public static Exception ThrowsAnyOf<TException1, TException2>(Action action) - { - return ThrowsAnyOf(new Type[] { typeof(TException1), typeof(TException2) }, action); - } - - public static Exception ThrowsAnyOf<TException1, TException2, TException3>(Action action) - { - return ThrowsAnyOf(new Type[] { typeof(TException1), typeof(TException2), typeof(TException3) }, action); - } - - public static Exception ThrowsAnyOf(IEnumerable<Type> expectedExceptionTypes, Action action) - { - var messagePrefix = $"Expected one of: {Collections.ToString(expectedExceptionTypes.Select(ex => ex.FullName).ToArray())}\nBut was:"; - Exception exception = null; - try - { - action(); - } - catch (Exception ex) when (!expectedExceptionTypes.Contains(ex.GetType())) - { - exception = ex; - } - catch (Exception ex) - { - return ex; // Success - } - string exString = exception == null ? "<null>" : exception.GetType().FullName; - Xunit.Assert.False(true, $"{messagePrefix} {exString}"); - return null; - } - - - private static string FormatMessage(string message, object[] args) - { - if (args?.Length > 0) - return string.Format(message, args); - else - return message; - } - } -} diff --git a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/BeforeAfterClass.cs b/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/BeforeAfterClass.cs deleted file mode 100644 index ed5fad3..0000000 --- a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/BeforeAfterClass.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Lucene.Net.Util; -using System; -using System.Collections.Concurrent; - -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> - /// A class to assist xUnit with running <see cref="LuceneTestCase.BeforeClass()"/> and - /// <see cref="LuceneTestCase.AfterClass()"/> methods during setup/teardown of a test class. - /// </summary> - public sealed class BeforeAfterClass : IDisposable - { - private readonly ConcurrentDictionary<Action, Action> beforeActions = new ConcurrentDictionary<Action, Action>(); - private readonly ConcurrentStack<Action> afterActions = new ConcurrentStack<Action>(); - - /// <summary> - /// Sets the <paramref name="after"/> and <paramref name="after"/> actions to run, and if this is the first - /// call for a given action, it runs <paramref name="before"/> immediately and stores <paramref name="after"/> until - /// <see cref="Dispose()"/> is called. - /// <para/> - /// This method is safe to call more than once with the same <paramref name="before"/> action, it will only function - /// if on the fist call. - /// <para/> - /// If called multiple times with different <paramref name="before"/> actions, each one is fired immediately. It is still - /// safe to call more than once with any of the <paramref name="before"/> actions that were previously provided. The - /// <paramref name="after"/> actions are stored on a stack and executed in reverse order, once for each call to <see cref="Dispose()"/>. - /// </summary> - /// <param name="before">The before action to run immediately, and only once.</param> - /// <param name="after">The after action that will be called to clean up during <see cref="Dispose()"/>.</param> - public void SetBeforeAfterClassActions(Action before, Action after) - { - // Only add each action once. - if (beforeActions.TryAdd(before, before)) - { - afterActions.Push(after); - before(); - } - } - - /// <summary> - /// Pops an after action from the top of the stack and runs it. - /// One action will be run on each call until the stack is exhausted. - /// </summary> - public void Dispose() - { - if (afterActions.TryPop(out Action after)) - after(); - } - } -} diff --git a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/SkipTestException.cs b/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/SkipTestException.cs deleted file mode 100644 index c367b56..0000000 --- a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/SkipTestException.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -#if FEATURE_SERIALIZABLE_EXCEPTIONS -using System.Runtime.Serialization; -#endif - -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> - /// An <see cref="Exception"/> that allows us to skip tests on xUnit. - /// </summary> - // LUCENENET: It is no longer good practice to use binary serialization. - // See: https://github.com/dotnet/corefx/issues/23584#issuecomment-325724568 -#if FEATURE_SERIALIZABLE_EXCEPTIONS - [Serializable] -#endif - public class SkipTestException : Exception - { - public SkipTestException(string message) - : base(message) - { - } - - public SkipTestException(string message, Exception innerException) - : base(message, innerException) - { - } - -#if FEATURE_SERIALIZABLE_EXCEPTIONS - public SkipTestException() - { } - - /// <summary> - /// Initializes a new instance of this class with serialized data. - /// </summary> - /// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param> - /// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param> - protected SkipTestException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } -#endif - } -} diff --git a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/SkippableFactAttribute.cs b/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/SkippableFactAttribute.cs deleted file mode 100644 index 5bc7dc2..0000000 --- a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/SkippableFactAttribute.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Xunit; -using Xunit.Sdk; - -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> - /// A skippable test. - /// </summary> - // LUCENENET: Grabbed example from https://github.com/xunit/samples.xunit/tree/5334ee9cf4a81f40dcb4cafabfeb098a555efb3d/DynamicSkipExample - [XunitTestCaseDiscoverer("Lucene.Net.TestFramework.XunitExtensions.SkippableFactDiscoverer", "Lucene.Net.TestFramework.xUnit")] - public class SkippableFactAttribute : FactAttribute - { - } -} diff --git a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/XunitExtensions/SkippableFactDiscoverer.cs b/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/XunitExtensions/SkippableFactDiscoverer.cs deleted file mode 100644 index bede2de..0000000 --- a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/XunitExtensions/SkippableFactDiscoverer.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Lucene.Net.TestFramework.XunitExtensions -{ - /* - * 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. - */ - - // LUCENENET: Grabbed example from https://github.com/xunit/samples.xunit/tree/5334ee9cf4a81f40dcb4cafabfeb098a555efb3d/DynamicSkipExample - public class SkippableFactDiscoverer : IXunitTestCaseDiscoverer - { - readonly IMessageSink diagnosticMessageSink; - - public SkippableFactDiscoverer(IMessageSink diagnosticMessageSink) - { - this.diagnosticMessageSink = diagnosticMessageSink; - } - - public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) - { - yield return new SkippableFactTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod); - } - } -} diff --git a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/XunitExtensions/SkippableFactMessageBus.cs b/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/XunitExtensions/SkippableFactMessageBus.cs deleted file mode 100644 index e706009..0000000 --- a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/XunitExtensions/SkippableFactMessageBus.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Linq; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Lucene.Net.TestFramework.XunitExtensions -{ - /* - * 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. - */ - - // LUCENENET: Grabbed example from https://github.com/xunit/samples.xunit/tree/5334ee9cf4a81f40dcb4cafabfeb098a555efb3d/DynamicSkipExample - public sealed class SkippableFactMessageBus : IMessageBus - { - readonly IMessageBus innerBus; - - public SkippableFactMessageBus(IMessageBus innerBus) - { - this.innerBus = innerBus; - } - - public int DynamicallySkippedTestCount { get; private set; } - - public void Dispose() { } - - public bool QueueMessage(IMessageSinkMessage message) - { - var testFailed = message as ITestFailed; - if (testFailed != null) - { - var exceptionType = testFailed.ExceptionTypes.FirstOrDefault(); - if (exceptionType == typeof(SkipTestException).FullName) - { - DynamicallySkippedTestCount++; - return innerBus.QueueMessage(new TestSkipped(testFailed.Test, testFailed.Messages.FirstOrDefault())); - } - } - - // Nothing we care about, send it on its way - return innerBus.QueueMessage(message); - } - } -} diff --git a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/XunitExtensions/SkippableFactTestCase.cs b/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/XunitExtensions/SkippableFactTestCase.cs deleted file mode 100644 index 20e4397..0000000 --- a/src/Lucene.Net.TestFramework.xUnit/Support/TestFramework/XunitExtensions/SkippableFactTestCase.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Lucene.Net.TestFramework.XunitExtensions -{ - /* - * 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. - */ - - // LUCENENET: Grabbed example from https://github.com/xunit/samples.xunit/tree/5334ee9cf4a81f40dcb4cafabfeb098a555efb3d/DynamicSkipExample - public class SkippableFactTestCase : XunitTestCase - { - [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] - public SkippableFactTestCase() { } - - public SkippableFactTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, object[] testMethodArguments = null) - : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments) { } - - public override async Task<RunSummary> RunAsync(IMessageSink diagnosticMessageSink, - IMessageBus messageBus, - object[] constructorArguments, - ExceptionAggregator aggregator, - CancellationTokenSource cancellationTokenSource) - { - var skipMessageBus = new SkippableFactMessageBus(messageBus); - var result = await base.RunAsync(diagnosticMessageSink, skipMessageBus, constructorArguments, aggregator, cancellationTokenSource); - if (skipMessageBus.DynamicallySkippedTestCount > 0) - { - result.Failed -= skipMessageBus.DynamicallySkippedTestCount; - result.Skipped += skipMessageBus.DynamicallySkippedTestCount; - } - - return result; - } - } -} diff --git a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj index 089383a..ba34529 100644 --- a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj +++ b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj @@ -39,10 +39,6 @@ </PropertyGroup> <Import Project="$(SolutionDir)build/Dependencies.props" /> - - <ItemGroup> - <Compile Include="..\Lucene.Net.TestFramework.NUnit\Support\TestFramework\Assert.cs" Link="Support\TestFramework\Assert.cs" /> - </ItemGroup> <ItemGroup> <None Remove="Util\europarl.lines.txt.gz" /> diff --git a/src/Lucene.Net.TestFramework/PortingWork-ReadMe.txt b/src/Lucene.Net.TestFramework/PortingWork-ReadMe.txt deleted file mode 100644 index 862d4ce..0000000 --- a/src/Lucene.Net.TestFramework/PortingWork-ReadMe.txt +++ /dev/null @@ -1,47 +0,0 @@ -# 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. - - -IMPORTANT - PLEASE READ IF YOU ARE PORTING test-framework CODE FROM JAVA - -If porting new code to Lucene.Net.TestFramework, make sure you NEVER call -System.Diagnostics.Debug.Assert. The design of the test framework expects -asserts to be included in the release, so we have added Lucene.Net.Diagnostics.Debug.Assert -methods to ensure this happens. - -This wasn't done to intentionally be confusing, it was done to keep the syntax similar -to Java and so if an assert is added later you don't really have to think about what -method to call. The only exception to this is when adding a new class file with asserts in it. -Make sure you place this import at the top of the file, comment included: - -using Debug = Lucene.Net.Diagnostics.Debug; // LUCENENET NOTE: We cannot use System.Diagnostics.Debug because those calls will be optimized out of the release! - -And then in the code, call Debug.Assert just like you normally would. - - -By the same token (pardon the pun) we are using our own Lucene.Net.Diagnostics.AssertionException -class instead of throwing the test framework's (i.e. NUnit or xUnit) exception. This is to normalize the behavior so -it doesn't change regardless of the test framework. Never throw an exception from the test framework -itself because it might not have compatible constructors or might be given special behaviors by the -test framework that are incompatible with Lucene.Net.TestFramework. - -If you need to throw an "AssertionError", put this declaration at the top of the class: - -using AssertionError = Lucene.Net.Diagnostics.AssertionException; - - -Do note that this exception is thrown and caught within Lucene.Net.TestFramework by some test mocks. \ No newline at end of file diff --git a/src/Lucene.Net.TestFramework.NUnit/Support/TestFramework/Assert.cs b/src/Lucene.Net.TestFramework/Support/TestFramework/Assert.cs similarity index 99% rename from src/Lucene.Net.TestFramework.NUnit/Support/TestFramework/Assert.cs rename to src/Lucene.Net.TestFramework/Support/TestFramework/Assert.cs index 85aae2c..ba09ca7 100644 --- a/src/Lucene.Net.TestFramework.NUnit/Support/TestFramework/Assert.cs +++ b/src/Lucene.Net.TestFramework/Support/TestFramework/Assert.cs @@ -29,7 +29,7 @@ namespace Lucene.Net.TestFramework */ /// <summary> - /// Facade for MSTest Assertions + /// Facade for NUnit Assertions /// </summary> internal partial class Assert { diff --git a/src/Lucene.Net/Lucene.Net.csproj b/src/Lucene.Net/Lucene.Net.csproj index 062565d..4a48416 100644 --- a/src/Lucene.Net/Lucene.Net.csproj +++ b/src/Lucene.Net/Lucene.Net.csproj @@ -97,9 +97,6 @@ <InternalsVisibleTo Include="Lucene.Net.Suggest" /> <InternalsVisibleTo Include="Lucene.Net.TestFramework" /> - <InternalsVisibleTo Include="Lucene.Net.TestFramework.MSTest" /> - <InternalsVisibleTo Include="Lucene.Net.TestFramework.NUnit" /> - <InternalsVisibleTo Include="Lucene.Net.TestFramework.xUnit" /> <InternalsVisibleTo Include="Lucene.Net.Tests._A-D" /> <InternalsVisibleTo Include="Lucene.Net.Tests._E-I" />
