[ https://issues.apache.org/jira/browse/AVRO-2161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16491614#comment-16491614 ]
ASF GitHub Bot commented on AVRO-2161: -------------------------------------- blachniet closed pull request #299: AVRO-2161: Upgrade to NUnit 3 URL: https://github.com/apache/avro/pull/299 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/lang/csharp/.gitignore b/lang/csharp/.gitignore index b8e088c61..944e701cc 100644 --- a/lang/csharp/.gitignore +++ b/lang/csharp/.gitignore @@ -17,6 +17,9 @@ /*.user /*.suo /_ReSharper.Avro +/.vs +obj/ + ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. diff --git a/lang/csharp/Avro.nunit b/lang/csharp/Avro.nunit deleted file mode 100644 index 7cbd7993c..000000000 --- a/lang/csharp/Avro.nunit +++ /dev/null @@ -1,35 +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. - --> -<NUnitProject> - <Settings activeconfig="Release" /> - <Config name="Debug" binpathtype="Auto"> - <assembly path="build/test/Debug/Avro.test.dll" /> - <assembly path="build/test/Debug/Avro.dll" /> - <assembly path="lib/main/Castle.Core.dll" /> - <assembly path="lib/main/Newtonsoft.Json.dll" /> - <assembly path="lib/test/nunit.framework.dll" /> - </Config> - <Config name="Release" binpathtype="Auto"> - <assembly path="build/test/Release/Avro.test.dll" /> - <assembly path="build/test/Release/Avro.dll" /> - <assembly path="lib/main/Castle.Core.dll" /> - <assembly path="lib/main/Newtonsoft.Json.dll" /> - <assembly path="lib/test/nunit.framework.dll" /> - </Config> -</NUnitProject> diff --git a/lang/csharp/README b/lang/csharp/README index 34909dd7e..5d422b117 100644 --- a/lang/csharp/README +++ b/lang/csharp/README @@ -3,9 +3,9 @@ a. Windows Prerequisites - Microsoft Visual C# Express 2010 + Microsoft Visual Studio Community 2017 -To build open Avro.sln solution in VC# Express 2010 and build from there. +To build, open Avro.sln solution in Microsoft Visual Studio Community 2017 and build from there. b. Linux @@ -17,6 +17,7 @@ follow the procedure described at http://badgerports.org/ To build issue the command: $ cd lang/csharp +$ mono nuget.exe restore then @@ -30,10 +31,13 @@ Note: In Ubuntu 12.04 (Precise Pangolin), please omit TARGETFRAMEWORKVERSION arg 2. Unit tests -This is a common procedure for both Windows and Linux. +a. Windows + +Open Avro.sln in Microsoft Visual Studio Community 2017. Run tests from the Test Explorer pane. + +b. Linux -To run unit-tests, please install NUnit 2.5 or above. From within the NUnit -GUI, open the project Avro.nunit and run the tests. +$ mono nunit3-console.exe ./build/test/Release/Avro.test.dll 3. Notes diff --git a/lang/csharp/lib/test/nunit.framework.dll b/lang/csharp/lib/test/nunit.framework.dll deleted file mode 100644 index 639dbb0dc..000000000 Binary files a/lang/csharp/lib/test/nunit.framework.dll and /dev/null differ diff --git a/lang/csharp/src/apache/test/Avro.test.csproj b/lang/csharp/src/apache/test/Avro.test.csproj index 841f4f2df..0a0fbf6ba 100644 --- a/lang/csharp/src/apache/test/Avro.test.csproj +++ b/lang/csharp/src/apache/test/Avro.test.csproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?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 @@ -14,155 +14,163 @@ 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 ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.30703</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{911D56AB-587B-4E5F-B5EA-D47D8A46F1FA}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>Avro.test</RootNamespace> - <AssemblyName>Avro.test</AssemblyName> +--> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{911D56AB-587B-4E5F-B5EA-D47D8A46F1FA}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Avro.test</RootNamespace> + <AssemblyName>Avro.test</AssemblyName> <TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' ">v3.5</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - <FileUpgradeFlags> - </FileUpgradeFlags> - <OldToolsVersion>3.5</OldToolsVersion> - <UpgradeBackupLocation /> - <PublishUrl>publish\</PublishUrl> - <Install>true</Install> - <InstallFrom>Disk</InstallFrom> - <UpdateEnabled>false</UpdateEnabled> - <UpdateMode>Foreground</UpdateMode> - <UpdateInterval>7</UpdateInterval> - <UpdateIntervalUnits>Days</UpdateIntervalUnits> - <UpdatePeriodically>false</UpdatePeriodically> - <UpdateRequired>false</UpdateRequired> - <MapFileExtensions>true</MapFileExtensions> - <ApplicationRevision>0</ApplicationRevision> - <ApplicationVersion>1.0.0.%2a</ApplicationVersion> - <IsWebBootstrapper>false</IsWebBootstrapper> - <UseApplicationTrust>false</UseApplicationTrust> - <BootstrapperEnabled>true</BootstrapperEnabled> + <FileAlignment>512</FileAlignment> + <FileUpgradeFlags> + </FileUpgradeFlags> + <OldToolsVersion>3.5</OldToolsVersion> + <UpgradeBackupLocation /> + <PublishUrl>publish\</PublishUrl> + <Install>true</Install> + <InstallFrom>Disk</InstallFrom> + <UpdateEnabled>false</UpdateEnabled> + <UpdateMode>Foreground</UpdateMode> + <UpdateInterval>7</UpdateInterval> + <UpdateIntervalUnits>Days</UpdateIntervalUnits> + <UpdatePeriodically>false</UpdatePeriodically> + <UpdateRequired>false</UpdateRequired> + <MapFileExtensions>true</MapFileExtensions> + <ApplicationRevision>0</ApplicationRevision> + <ApplicationVersion>1.0.0.%2a</ApplicationVersion> + <IsWebBootstrapper>false</IsWebBootstrapper> + <UseApplicationTrust>false</UseApplicationTrust> + <BootstrapperEnabled>true</BootstrapperEnabled> <TargetFrameworkProfile /> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>..\..\..\build\test\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>none</DebugType> - <Optimize>true</Optimize> - <OutputPath>..\..\..\build\test\Release\</OutputPath> - <DefineConstants> - </DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> - </PropertyGroup> - <ItemGroup> - <Reference Include="Castle.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\..\..\..\lang\csharp\lib\main\Castle.Core.dll</HintPath> - </Reference> - <Reference Include="nunit.framework, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\..\..\lib\test\nunit.framework.dll</HintPath> - </Reference> - <Reference Include="System" /> - <Reference Include="System.Core" /> - <Reference Include="System.Xml.Linq" /> - <Reference Include="System.Data.DataSetExtensions" /> - <Reference Include="System.Data" /> - <Reference Include="System.Xml" /> - </ItemGroup> - <ItemGroup> - <Compile Include="CodGen\CodeGenTest.cs" /> - <Compile Include="File\FileTests.cs" /> - <Compile Include="Generic\GenericTests.cs" /> - <Compile Include="IO\BinaryCodecTests.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\All.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\AllCallback.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\AllEnum.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\AllTestRecord.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\AllTestRecordPartial.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\FixedTest.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\Kind.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\Mail.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\MailCallback.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\MD5.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\Message.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\Simple.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\SimpleCallback.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\TestError.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\TestRecord.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\TestRecordExtensions.cs" /> - <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\TestRecordWithUnion.cs" /> - <Compile Include="Ipc\HttpClientServerTest.cs" /> - <Compile Include="Ipc\LocalTransceiverTest.cs" /> - <Compile Include="Ipc\MailResponder.cs" /> - <Compile Include="Ipc\SerializationTest.cs" /> - <Compile Include="Ipc\SocketServerConcurrentExecutionTest.cs" /> - <Compile Include="Ipc\SocketServerTest.cs" /> - <Compile Include="Ipc\SocketServerWithCallbacksTest.cs" /> - <Compile Include="Ipc\SocketTransceiverWhenServerStopsTest.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="Protocol\ProtocolTest.cs" /> - <Compile Include="Schema\AliasTest.cs" /> - <Compile Include="Schema\SchemaNormalizationTests.cs" /> - <Compile Include="Schema\SchemaTests.cs" /> - <Compile Include="Specific\SpecificTests.cs" /> - <Compile Include="Utils\CaseFinder.cs" /> - <Compile Include="Utils\CaseFinderTests.cs" /> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\ipc\Avro.ipc.csproj"> - <Project>{3b05043a-dc6c-49b6-85bf-9ab055d0b414}</Project> - <Name>Avro.ipc</Name> - </ProjectReference> - <ProjectReference Include="..\main\Avro.main.csproj"> - <Project>{A0A5CA3C-F58C-4D07-98B0-2C7B62AB20F0}</Project> - <Name>Avro.main</Name> - </ProjectReference> - </ItemGroup> - <ItemGroup> - <BootstrapperPackage Include=".NETFramework,Version=v3.5"> - <Visible>False</Visible> - <ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName> - <Install>true</Install> - </BootstrapperPackage> - <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> - <Visible>False</Visible> - <ProductName>.NET Framework 3.5 SP1</ProductName> - <Install>false</Install> - </BootstrapperPackage> - <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> - <Visible>False</Visible> - <ProductName>Windows Installer 3.1</ProductName> - <Install>true</Install> - </BootstrapperPackage> - </ItemGroup> - <ItemGroup> - <EmbeddedResource Include="..\..\..\..\..\share\test\schemas\mail.avpr"> - <Link>Ipc\mail.avpr</Link> - </EmbeddedResource> - </ItemGroup> - <ItemGroup /> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <NuGetPackageImportStamp> + </NuGetPackageImportStamp> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\build\test\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>none</DebugType> + <Optimize>true</Optimize> + <OutputPath>..\..\..\build\test\Release\</OutputPath> + <DefineConstants> + </DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> + </PropertyGroup> + <ItemGroup> + <Reference Include="Castle.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\..\..\lang\csharp\lib\main\Castle.Core.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="CodGen\CodeGenTest.cs" /> + <Compile Include="File\FileTests.cs" /> + <Compile Include="Generic\GenericTests.cs" /> + <Compile Include="IO\BinaryCodecTests.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\All.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\AllCallback.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\AllEnum.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\AllTestRecord.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\AllTestRecordPartial.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\FixedTest.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\Kind.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\Mail.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\MailCallback.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\MD5.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\Message.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\Simple.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\SimpleCallback.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\TestError.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\TestRecord.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\TestRecordExtensions.cs" /> + <Compile Include="Ipc\GeneratedFiles\org\apache\avro\test\TestRecordWithUnion.cs" /> + <Compile Include="Ipc\HttpClientServerTest.cs" /> + <Compile Include="Ipc\LocalTransceiverTest.cs" /> + <Compile Include="Ipc\MailResponder.cs" /> + <Compile Include="Ipc\SerializationTest.cs" /> + <Compile Include="Ipc\SocketServerConcurrentExecutionTest.cs" /> + <Compile Include="Ipc\SocketServerTest.cs" /> + <Compile Include="Ipc\SocketServerWithCallbacksTest.cs" /> + <Compile Include="Ipc\SocketTransceiverWhenServerStopsTest.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Protocol\ProtocolTest.cs" /> + <Compile Include="Schema\AliasTest.cs" /> + <Compile Include="Schema\SchemaNormalizationTests.cs" /> + <Compile Include="Schema\SchemaTests.cs" /> + <Compile Include="Specific\SpecificTests.cs" /> + <Compile Include="Utils\CaseFinder.cs" /> + <Compile Include="Utils\CaseFinderTests.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\ipc\Avro.ipc.csproj"> + <Project>{3b05043a-dc6c-49b6-85bf-9ab055d0b414}</Project> + <Name>Avro.ipc</Name> + </ProjectReference> + <ProjectReference Include="..\main\Avro.main.csproj"> + <Project>{A0A5CA3C-F58C-4D07-98B0-2C7B62AB20F0}</Project> + <Name>Avro.main</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include=".NETFramework,Version=v3.5"> + <Visible>False</Visible> + <ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> + <Visible>False</Visible> + <ProductName>Windows Installer 3.1</ProductName> + <Install>true</Install> + </BootstrapperPackage> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="..\..\..\..\..\share\test\schemas\mail.avpr"> + <Link>Ipc\mail.avpr</Link> + </EmbeddedResource> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <PackageReference Include="nunit"> + <Version>3.10.1</Version> + </PackageReference> + <PackageReference Include="nunit3testadapter"> + <Version>3.10.0</Version> + </PackageReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> - --> + --> </Project> \ No newline at end of file diff --git a/lang/csharp/src/apache/test/CodGen/CodeGenTest.cs b/lang/csharp/src/apache/test/CodGen/CodeGenTest.cs index c5428b31e..93dca8da4 100644 --- a/lang/csharp/src/apache/test/CodGen/CodeGenTest.cs +++ b/lang/csharp/src/apache/test/CodGen/CodeGenTest.cs @@ -1,4 +1,4 @@ -/** +/** * 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 @@ -48,7 +48,7 @@ class CodeGenTest { ""name"" : ""string"", ""type"" : { ""type"": ""fixed"", ""size"": 16, ""name"": ""static"" } } ] } -", new object[] {"com.base.ClassKeywords", typeof(int), typeof(long), typeof(bool), typeof(double), typeof(float), typeof(byte[]), typeof(string),typeof(object),"com.base.class", "com.base.static"})] +", new object[] {"com.base.ClassKeywords", typeof(int), typeof(long), typeof(bool), typeof(double), typeof(float), typeof(byte[]), typeof(string),typeof(object),"com.base.class", "com.base.static"}, TestName = "TestCodeGen0")] [TestCase(@"{ ""type"" : ""record"", ""name"" : ""SchemaObject"", @@ -67,7 +67,7 @@ class CodeGenTest } ] } -", new object[] { "schematest.SchemaObject", typeof(IList<object>) })] +", new object[] { "schematest.SchemaObject", typeof(IList<object>) }, TestName = "TestCodeGen1")] public static void TestCodeGen(string str, object[] result) { Schema schema = Schema.Parse(str); @@ -112,7 +112,7 @@ private static CompilerResults GenerateAssembly(CodeGen schema) var comparam = new CompilerParameters(new string[] { "mscorlib.dll" }); comparam.ReferencedAssemblies.Add("System.dll"); - comparam.ReferencedAssemblies.Add("Avro.dll"); + comparam.ReferencedAssemblies.Add(Path.Combine(TestContext.CurrentContext.TestDirectory, "Avro.dll")); comparam.GenerateInMemory = true; var ccp = new CSharpCodeProvider(); var units = new[] { compileUnit }; diff --git a/lang/csharp/src/apache/test/File/FileTests.cs b/lang/csharp/src/apache/test/File/FileTests.cs index b3dbfb28f..0d7433a8b 100644 --- a/lang/csharp/src/apache/test/File/FileTests.cs +++ b/lang/csharp/src/apache/test/File/FileTests.cs @@ -1,4 +1,4 @@ -/** +/** * 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 @@ -40,15 +40,15 @@ public class FileTests /// <param name="schemaStr"></param> /// <param name="recs"></param> /// <param name="codecType"></param> - [TestCase(specificSchema, new object[] { new object[] { "John", 23 } }, Codec.Type.Deflate)] - [TestCase(specificSchema, new object[] { new object[] { "Jane", 23 } }, Codec.Type.Deflate)] - [TestCase(specificSchema, new object[] { new object[] { "John", 23 }, new object[] { "Jane", 99 }, new object[] { "Jeff", 88 } }, Codec.Type.Deflate)] + [TestCase(specificSchema, new object[] { new object[] { "John", 23 } }, Codec.Type.Deflate, TestName = "TestSpecificData0")] + [TestCase(specificSchema, new object[] { new object[] { "Jane", 23 } }, Codec.Type.Deflate, TestName = "TestSpecificData1")] + [TestCase(specificSchema, new object[] { new object[] { "John", 23 }, new object[] { "Jane", 99 }, new object[] { "Jeff", 88 } }, Codec.Type.Deflate, TestName = "TestSpecificData2")] [TestCase(specificSchema, new object[] { new object[] {"John", 23}, new object[] { "Jane", 99 }, new object[] { "Jeff", 88 }, new object[] {"James", 13}, new object[] { "June", 109 }, new object[] { "Lloyd", 18 }, - new object[] {"Jenny", 3}, new object[] { "Bob", 9 }, new object[] { null, 48 }}, Codec.Type.Deflate)] - [TestCase(specificSchema, new object[] { new object[] { "John", 23 } }, Codec.Type.Null)] - [TestCase(specificSchema, new object[] { new object[] { "Jane", 23 } }, Codec.Type.Null)] - [TestCase(specificSchema, new object[] { new object[] { "John", 23 }, new object[] { "Jane", 99 }, new object[] { "Jeff", 88 } }, Codec.Type.Null)] + new object[] {"Jenny", 3}, new object[] { "Bob", 9 }, new object[] { null, 48 }}, Codec.Type.Deflate, TestName = "TestSpecificData3")] + [TestCase(specificSchema, new object[] { new object[] { "John", 23 } }, Codec.Type.Null, TestName = "TestSpecificData4")] + [TestCase(specificSchema, new object[] { new object[] { "Jane", 23 } }, Codec.Type.Null, TestName = "TestSpecificData5")] + [TestCase(specificSchema, new object[] { new object[] { "John", 23 }, new object[] { "Jane", 99 }, new object[] { "Jeff", 88 } }, Codec.Type.Null, TestName = "TestSpecificData6")] [TestCase(specificSchema, new object[] { new object[] {"John", 23}, new object[] { "Jane", 99 }, new object[] { "Jeff", 88 }, new object[] {"James", 13}, new object[] { "June", 109 }, new object[] { "Lloyd", 18 }, new object[] {"Jamie", 53}, new object[] { "Fanessa", 101 }, new object[] { "Kan", 18 }, @@ -59,7 +59,7 @@ public class FileTests new object[] {"Ernie", 43}, new object[] { "Joel", 99 }, new object[] { "Dan", 78 }, new object[] {"Dave", 103}, new object[] { "Hillary", 79 }, new object[] { "Grant", 88 }, new object[] {"JJ", 14}, new object[] { "Bill", 90 }, new object[] { "Larry", 4 }, - new object[] {"Jenny", 3}, new object[] { "Bob", 9 }, new object[] { null, 48 }}, Codec.Type.Null)] + new object[] {"Jenny", 3}, new object[] { "Bob", 9 }, new object[] { null, 48 }}, Codec.Type.Null, TestName = "TestSpecificData7")] public void TestSpecificData(string schemaStr, object[] recs, Codec.Type codecType) { // create and write out diff --git a/lang/csharp/src/apache/test/Generic/GenericTests.cs b/lang/csharp/src/apache/test/Generic/GenericTests.cs index 19951fd0b..25450e381 100644 --- a/lang/csharp/src/apache/test/Generic/GenericTests.cs +++ b/lang/csharp/src/apache/test/Generic/GenericTests.cs @@ -1,4 +1,4 @@ -/** +/** * 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 @@ -121,11 +121,17 @@ public void TestUnion_record(string unionSchema, string recordSchema, object[] v [TestCase("[{\"type\": \"enum\", \"symbols\": [\"s1\", \"s2\"], \"name\": \"e\"}, \"string\"]", "{\"type\": \"enum\", \"symbols\": [\"s1\", \"s2\"], \"name\": \"e\"}", "s2")] [TestCase("[{\"type\": \"enum\", \"symbols\": [\"s1\", \"s2\"], \"name\": \"e\"}, \"string\"]", - "{\"type\": \"enum\", \"symbols\": [\"s1\", \"s2\"], \"name\": \"e\"}", "s3", - ExpectedException = typeof(AvroException))] - public void TestUnion_enum(string unionSchema, string enumSchema, string value) + "{\"type\": \"enum\", \"symbols\": [\"s1\", \"s2\"], \"name\": \"e\"}", "s3", typeof(AvroException))] + public void TestUnion_enum(string unionSchema, string enumSchema, string value, Type expectedExceptionType = null) { - test(unionSchema, mkEnum(enumSchema, value)); + if (expectedExceptionType != null) + { + Assert.Throws(expectedExceptionType, () => { test(unionSchema, mkEnum(enumSchema, value)); }); + } + else + { + test(unionSchema, mkEnum(enumSchema, value)); + } } @@ -139,14 +145,19 @@ public void TestUnion_map(string unionSchema, string mapSchema, object[] value) [TestCase("[{\"type\": \"fixed\", \"size\": 2, \"name\": \"f\"}, \"string\"]", "{\"type\": \"fixed\", \"size\": 2, \"name\": \"f\"}", new byte[] { 1, 2 })] [TestCase("[{\"type\": \"fixed\", \"size\": 2, \"name\": \"f\"}, \"string\"]", - "{\"type\": \"fixed\", \"size\": 2, \"name\": \"f\"}", new byte[] { 1, 2, 3 }, - ExpectedException = typeof(AvroException))] + "{\"type\": \"fixed\", \"size\": 2, \"name\": \"f\"}", new byte[] { 1, 2, 3 }, typeof(AvroException))] [TestCase("[{\"type\": \"fixed\", \"size\": 2, \"name\": \"f\"}, \"string\"]", - "{\"type\": \"fixed\", \"size\": 3, \"name\": \"f\"}", new byte[] { 1, 2, 3 }, - ExpectedException = typeof(AvroException))] - public void TestUnion_fixed(string unionSchema, string fixedSchema, byte[] value) + "{\"type\": \"fixed\", \"size\": 3, \"name\": \"f\"}", new byte[] { 1, 2, 3 }, typeof(AvroException))] + public void TestUnion_fixed(string unionSchema, string fixedSchema, byte[] value, Type expectedExceptionType = null) { - test(unionSchema, mkFixed(fixedSchema, value)); + if (expectedExceptionType != null) + { + Assert.Throws(expectedExceptionType, () => { test(unionSchema, mkFixed(fixedSchema, value)); }); + } + else + { + test(unionSchema, mkFixed(fixedSchema, value)); + } } public void TestResolution<T, S>(string writerSchema, T actual, string readerSchema, S expected) @@ -300,89 +311,124 @@ private static void testResolutionMismatch<T>(string writerSchema, T value, stri deserialize<object>(ms, ws, Schema.Parse(readerSchema)); } - [TestCase("boolean", true, "null", ExpectedException = typeof(AvroException))] - [TestCase("int", 10, "boolean", ExpectedException = typeof(AvroException))] - [TestCase("int", 10, "string", ExpectedException = typeof(AvroException))] - [TestCase("int", 10, "bytes", ExpectedException = typeof(AvroException))] + [TestCase("boolean", true, "null", typeof(AvroException))] + [TestCase("int", 10, "boolean", typeof(AvroException))] + [TestCase("int", 10, "string", typeof(AvroException))] + [TestCase("int", 10, "bytes", typeof(AvroException))] [TestCase("int", 10, "{\"type\":\"record\",\"name\":\"r\",\"fields\":[{\"name\":\"f\", \"type\":\"int\"}]}", - ExpectedException = typeof(AvroException))] - [TestCase("int", 10, "{\"type\":\"enum\",\"name\":\"e\",\"symbols\":[\"s\", \"t\"]}", ExpectedException = typeof(AvroException))] - [TestCase("int", 10, "{\"type\":\"array\",\"items\":\"int\"}", ExpectedException = typeof(AvroException))] - [TestCase("int", 10, "{\"type\":\"map\",\"values\":\"int\"}", ExpectedException = typeof(AvroException))] - [TestCase("int", 10, "[\"string\", \"bytes\"]", ExpectedException = typeof(AvroException))] - [TestCase("int", 10, "{\"type\":\"fixed\",\"name\":\"f\",\"size\":2}", ExpectedException = typeof(AvroException))] + typeof(AvroException))] + [TestCase("int", 10, "{\"type\":\"enum\",\"name\":\"e\",\"symbols\":[\"s\", \"t\"]}", typeof(AvroException))] + [TestCase("int", 10, "{\"type\":\"array\",\"items\":\"int\"}", typeof(AvroException))] + [TestCase("int", 10, "{\"type\":\"map\",\"values\":\"int\"}", typeof(AvroException))] + [TestCase("int", 10, "[\"string\", \"bytes\"]", typeof(AvroException))] + [TestCase("int", 10, "{\"type\":\"fixed\",\"name\":\"f\",\"size\":2}", typeof(AvroException))] [TestCase("{\"type\":\"array\",\"items\":\"int\"}", new int[] { 10 }, - "\"boolean\"", ExpectedException = typeof(AvroException))] + "\"boolean\"", typeof(AvroException))] [TestCase("{\"type\":\"array\",\"items\":\"int\"}", new int[] { 10 }, - "{\"type\":\"array\",\"items\":\"string\"}", ExpectedException = typeof(AvroException))] - [TestCase("[\"int\", \"boolean\"]", 10, "[\"string\", \"bytes\"]", ExpectedException = typeof(AvroException))] - [TestCase("[\"int\", \"boolean\"]", 10, "\"string\"", ExpectedException = typeof(AvroException))] - public void TestResolutionMismatch_simple(string writerSchema, object value, string readerSchema) + "{\"type\":\"array\",\"items\":\"string\"}", typeof(AvroException))] + [TestCase("[\"int\", \"boolean\"]", 10, "[\"string\", \"bytes\"]", typeof(AvroException))] + [TestCase("[\"int\", \"boolean\"]", 10, "\"string\"", typeof(AvroException))] + public void TestResolutionMismatch_simple(string writerSchema, object value, string readerSchema, Type expectedExceptionType = null) { - testResolutionMismatch(writerSchema, value, readerSchema); + if (expectedExceptionType != null) + { + Assert.Throws(expectedExceptionType, () => { testResolutionMismatch(writerSchema, value, readerSchema); }); + } + else + { + testResolutionMismatch(writerSchema, value, readerSchema); + } } [TestCase("{\"type\":\"record\",\"name\":\"r\",\"fields\":" + "[{\"name\":\"f1\",\"type\":[\"int\", \"null\"]},{\"name\":\"f2\",\"type\":\"int\"}]}", new object[] { "f1", 101, "f2", 100 }, "int", - ExpectedException = typeof(AvroException), Description = "Non-record schema")] + typeof(AvroException), Description = "Non-record schema")] [TestCase("{\"type\":\"record\",\"name\":\"r\",\"fields\":" + "[{\"name\":\"f1\",\"type\":[\"int\", \"null\"]},{\"name\":\"f2\",\"type\":\"int\"}]}", new object[] { "f1", 101, "f2", 100 }, "{\"type\":\"record\",\"name\":\"s\",\"fields\":" + "[{\"name\":\"f2\",\"type\":\"int\"}]}", - ExpectedException = typeof(AvroException), Description = "Name mismatch")] + typeof(AvroException), Description = "Name mismatch")] [TestCase("{\"type\":\"record\",\"name\":\"r\",\"fields\":" + "[{\"name\":\"f1\",\"type\":[\"int\", \"null\"]},{\"name\":\"f2\",\"type\":\"int\"}]}", new object[] { "f1", 101, "f2", 100 }, "{\"type\":\"record\",\"name\":\"r\",\"fields\":" + "[{\"name\":\"f2\",\"type\":\"string\"}]}", - ExpectedException = typeof(AvroException), Description = "incompatible field")] + typeof(AvroException), Description = "incompatible field")] [TestCase("{\"type\":\"record\",\"name\":\"r\",\"fields\":" + "[{\"name\":\"f1\",\"type\":[\"int\", \"null\"]},{\"name\":\"f2\",\"type\":\"int\"}]}", new object[] { "f1", 101, "f2", 100 }, "{\"type\":\"record\",\"name\":\"r\",\"fields\":" + "[{\"name\":\"f3\",\"type\":\"string\"}]}", - ExpectedException = typeof(AvroException), Description = "new field without default")] - public void TestResolutionMismatch_record(string ws, object[] actual, string rs) + typeof(AvroException), Description = "new field without default")] + public void TestResolutionMismatch_record(string ws, object[] actual, string rs, Type expectedExceptionType = null) { - testResolutionMismatch(ws, mkRecord(actual, Schema.Parse(ws) as RecordSchema), rs); + if (expectedExceptionType != null) + { + Assert.Throws(expectedExceptionType, () => { testResolutionMismatch(ws, mkRecord(actual, Schema.Parse(ws) as RecordSchema), rs); }); + } + else + { + testResolutionMismatch(ws, mkRecord(actual, Schema.Parse(ws) as RecordSchema), rs); + } } [TestCase("{\"type\":\"enum\",\"name\":\"e\",\"symbols\":[\"s\", \"t\"]}", "s", "int", - ExpectedException = typeof(AvroException), Description = "Non-enum schema")] + typeof(AvroException), Description = "Non-enum schema")] [TestCase("{\"type\":\"enum\",\"name\":\"e\",\"symbols\":[\"s\", \"t\"]}", "s", "{\"type\":\"enum\",\"name\":\"f\",\"symbols\":[\"s\", \"t\"]}", - ExpectedException = typeof(AvroException), Description = "Name mismatch")] + typeof(AvroException), Description = "Name mismatch")] [TestCase("{\"type\":\"enum\",\"name\":\"e\",\"symbols\":[\"s\", \"t\"]}", "s", "{\"type\":\"enum\",\"name\":\"f\",\"symbols\":[\"t\", \"u\"]}", - ExpectedException = typeof(AvroException), Description = "Incompatible symbols")] - public void TestResolutionMismatch_enum(string ws, string value, string rs) + typeof(AvroException), Description = "Incompatible symbols")] + public void TestResolutionMismatch_enum(string ws, string value, string rs, Type expectedExceptionType = null) { - testResolutionMismatch(ws, mkEnum(ws, value), rs); + if (expectedExceptionType != null) + { + Assert.Throws(expectedExceptionType, () => { testResolutionMismatch(ws, mkEnum(ws, value), rs); }); + } + else + { + testResolutionMismatch(ws, mkEnum(ws, value), rs); + } } [TestCase("{\"type\":\"map\",\"values\":\"int\"}", new object[] { "a", 0 }, "int", - ExpectedException = typeof(AvroException), Description = "Non-map schema")] + typeof(AvroException), Description = "Non-map schema")] [TestCase("{\"type\":\"map\",\"values\":\"int\"}", new object[] { "a", 0 }, "{\"type\":\"map\",\"values\":\"string\"}", - ExpectedException = typeof(AvroException), Description = "Name mismatch")] - public void TestResolutionMismatch_map(string ws, object[] value, string rs) + typeof(AvroException), Description = "Name mismatch")] + public void TestResolutionMismatch_map(string ws, object[] value, string rs, Type expectedExceptionType = null) { - testResolutionMismatch(ws, mkMap(value), rs); + if (expectedExceptionType != null) + { + Assert.Throws(expectedExceptionType, () => { testResolutionMismatch(ws, mkMap(value), rs); }); + } + else + { + testResolutionMismatch(ws, mkMap(value), rs); + } } [TestCase("{\"type\":\"fixed\",\"name\":\"f\",\"size\":2}", new byte[] { 1, 1 }, "int", - ExpectedException = typeof(AvroException), Description = "Non-fixed schema")] + typeof(AvroException), Description = "Non-fixed schema")] [TestCase("{\"type\":\"fixed\",\"name\":\"f\",\"size\":2}", new byte[] { 1, 1 }, "{\"type\":\"fixed\",\"name\":\"g\",\"size\":2}", - ExpectedException = typeof(AvroException), Description = "Name mismatch")] + typeof(AvroException), Description = "Name mismatch")] [TestCase("{\"type\":\"fixed\",\"name\":\"f\",\"size\":2}", new byte[] { 1, 1 }, "{\"type\":\"fixed\",\"name\":\"f\",\"size\":1}", - ExpectedException = typeof(AvroException), Description = "Size mismatch")] - public void TestResolutionMismatch_fixed(string ws, byte[] value, string rs) + typeof(AvroException), Description = "Size mismatch")] + public void TestResolutionMismatch_fixed(string ws, byte[] value, string rs, Type expectedExceptionType = null) { - testResolutionMismatch(ws, mkFixed(ws, value), rs); + if (expectedExceptionType != null) + { + Assert.Throws(expectedExceptionType, () => { testResolutionMismatch(ws, mkFixed(ws, value), rs); }); + } + else + { + testResolutionMismatch(ws, mkFixed(ws, value), rs); + } } private static GenericRecord mkRecord(object[] kv, RecordSchema s) diff --git a/lang/csharp/src/apache/test/Ipc/HttpClientServerTest.cs b/lang/csharp/src/apache/test/Ipc/HttpClientServerTest.cs index 5c2ddf6cd..36979006e 100644 --- a/lang/csharp/src/apache/test/Ipc/HttpClientServerTest.cs +++ b/lang/csharp/src/apache/test/Ipc/HttpClientServerTest.cs @@ -1,4 +1,4 @@ -/** +/** * 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 @@ -42,7 +42,7 @@ public class HttpClientServerTest const string URL = @"http://localhost:18080/avro/test/ipc/mailResponder/"; - [TestFixtureSetUp] + [OneTimeSetUp] //[TestInitialize] public void Init() { @@ -58,7 +58,7 @@ public void Init() proxy = new GenericRequestor(transceiver, MailResponder.Protocol); } - [TestFixtureTearDown] + [OneTimeTearDown] //[TestCleanup] public void Cleanup() { diff --git a/lang/csharp/src/apache/test/Ipc/SerializationTest.cs b/lang/csharp/src/apache/test/Ipc/SerializationTest.cs index 84104a0e5..58198023c 100644 --- a/lang/csharp/src/apache/test/Ipc/SerializationTest.cs +++ b/lang/csharp/src/apache/test/Ipc/SerializationTest.cs @@ -1,4 +1,4 @@ -/** +/** * 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 @@ -60,7 +60,7 @@ public override AllTestRecord echo(AllTestRecord allTest) private SocketTransceiver transceiver; private All simpleClient; - [TestFixtureSetUp] + [OneTimeSetUp] public void Init() { var mailResponder = new SpecificResponder<All>(new AllImpl()); @@ -73,7 +73,7 @@ public void Init() simpleClient = SpecificRequestor.CreateClient<All>(transceiver); } - [TestFixtureTearDown] + [OneTimeTearDown] public void Cleanup() { server.Stop(); @@ -150,4 +150,4 @@ private static AllTestRecord CreateExpectedTestData() }; } } -} \ No newline at end of file +} diff --git a/lang/csharp/src/apache/test/Ipc/SocketServerTest.cs b/lang/csharp/src/apache/test/Ipc/SocketServerTest.cs index 1a1747bfa..9d091ae3d 100644 --- a/lang/csharp/src/apache/test/Ipc/SocketServerTest.cs +++ b/lang/csharp/src/apache/test/Ipc/SocketServerTest.cs @@ -1,4 +1,4 @@ -/** +/** * 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 @@ -33,7 +33,7 @@ public class SocketServerTest private SocketTransceiver transceiver; private GenericRequestor proxy; - [TestFixtureSetUp] + [OneTimeSetUp] public void Init() { mailResponder = new MailResponder(); @@ -45,7 +45,7 @@ public void Init() proxy = new GenericRequestor(transceiver, MailResponder.Protocol); } - [TestFixtureTearDown] + [OneTimeTearDown] public void Cleanup() { server.Stop(); @@ -184,4 +184,4 @@ public void TestRequestResponse() } } } -} \ No newline at end of file +} diff --git a/lang/csharp/src/apache/test/Ipc/SocketServerWithCallbacksTest.cs b/lang/csharp/src/apache/test/Ipc/SocketServerWithCallbacksTest.cs index c625e63ec..d8fb57d00 100644 --- a/lang/csharp/src/apache/test/Ipc/SocketServerWithCallbacksTest.cs +++ b/lang/csharp/src/apache/test/Ipc/SocketServerWithCallbacksTest.cs @@ -1,4 +1,4 @@ -/** +/** * 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 @@ -37,7 +37,7 @@ public class SocketServerWithCallbacksTest private SocketTransceiver transceiver; private SimpleCallback simpleClient; - [TestFixtureSetUp] + [OneTimeSetUp] public void Init() { var responder = new SpecificResponder<Simple>(new SimpleImpl()); @@ -48,7 +48,7 @@ public void Init() simpleClient = SpecificRequestor.CreateClient<SimpleCallback>(transceiver); } - [TestFixtureTearDown] + [OneTimeTearDown] public void TearDown() { try @@ -803,4 +803,4 @@ public override void ack() } } -} \ No newline at end of file +} diff --git a/lang/csharp/src/apache/test/Protocol/ProtocolTest.cs b/lang/csharp/src/apache/test/Protocol/ProtocolTest.cs index 19eeee8b3..453d2ed1b 100644 --- a/lang/csharp/src/apache/test/Protocol/ProtocolTest.cs +++ b/lang/csharp/src/apache/test/Protocol/ProtocolTest.cs @@ -1,4 +1,4 @@ -/** +/** * 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 @@ -49,7 +49,7 @@ public class ProtocolTest ""errors"": [""Curse"", ""CurseMore""] } } -}", true)] +}", true, TestName = "TestProtocol0")] [TestCase(@"{ ""protocol"" : ""MyProtocol"", ""namespace"" : ""com.foo"", @@ -107,7 +107,7 @@ public class ProtocolTest ""type"" : ""int"" } ] -}", true)] +}", true, TestName = "TestProtocol1")] [TestCase(@"{ ""protocol"" : ""MyProtocol"", ""namespace"" : ""com.bar"", @@ -168,7 +168,7 @@ public class ProtocolTest ""type"" : ""int"" } ] -}", true)] +}", true, TestName = "TestProtocol2")] public static void TestProtocol(string str, bool valid) { Protocol protocol = Protocol.Parse(str); @@ -221,7 +221,7 @@ public static void TestProtocol(string str, bool valid) } } }", - true,true)] + true,true, TestName = "TestProtocolHash_ProtocolsMatch")] // Protocols match, order of schemas in 'types' are different [TestCase( @"{ @@ -262,7 +262,7 @@ public static void TestProtocol(string str, bool valid) } } }", - false,true)] + false,true, TestName = "TestProtocolHash_ProtocolsMatch_OrderOfSchemasInTypesAreDifferent")] // Name of protocol is different [TestCase( @"{ @@ -303,7 +303,7 @@ public static void TestProtocol(string str, bool valid) } } }", - false,false)] + false,false, TestName = "TestProtocolHash_NameOfProtocolIsDifferent")] // Name of a message request is different: 'hi' [TestCase( @"{ @@ -344,7 +344,7 @@ public static void TestProtocol(string str, bool valid) } } }", - false,false)] + false,false, TestName = "TestProtocolHash_NameOfMessageRequestIsDifferent")] // Name of a type is different : Curse1 [TestCase( @"{ @@ -385,7 +385,7 @@ public static void TestProtocol(string str, bool valid) } } }", - false,false)] + false,false, TestName = "TestProtocolHash_NameOfTypeIsDifferent_Curse1")] // Name of a record field is different: 'mymessage' [TestCase( @"{ @@ -426,7 +426,7 @@ public static void TestProtocol(string str, bool valid) } } }", - false,false)] + false,false, TestName = "TestProtocolHash_NameOfRecordFieldIsDifferent_MyMessage")] public static void TestProtocolHash(string str1, string str2, bool md5_equal, bool hash_equal) { Protocol protocol1 = Protocol.Parse(str1); diff --git a/lang/csharp/src/apache/test/Schema/AliasTest.cs b/lang/csharp/src/apache/test/Schema/AliasTest.cs index 96dec9ebc..c480076d3 100644 --- a/lang/csharp/src/apache/test/Schema/AliasTest.cs +++ b/lang/csharp/src/apache/test/Schema/AliasTest.cs @@ -1,4 +1,4 @@ -/** +/** * 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 @@ -143,64 +143,64 @@ public void TestFixedAliasesResolution(string reader, string writer, bool canrea @"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f2"",""type"": ""int""}]}", - true)] + true, TestName = "TestRecordAliasesResolution1")] [TestCase(2,@"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f2"",""type"": ""int""}]}", @"{""type"":""record"",""name"":""NewRec"", ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f2"",""type"": ""int""}]}", - false)] + false, TestName = "TestRecordAliasesResolution2")] [TestCase(3,@"{""type"":""record"",""name"":""Rec"", ""aliases"":[""NewRec""], ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f2"",""type"": ""int""}]}", @"{""type"":""record"",""name"":""NewRec"", ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f2"",""type"": ""int""}]}", - true)] + true, TestName = "TestRecordAliasesResolution3")] [TestCase(4,@"{""type"":""record"",""name"":""Rec"", ""aliases"":[""OtherRec"",""DiffRec""], ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f2"",""type"": ""int""}]}", @"{""type"":""record"",""name"":""NewRec"", ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f2"",""type"": ""int""}]}", - false)] + false, TestName = "TestRecordAliasesResolution4")] [TestCase(5,@"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f3"",""type"": ""int""}]}", @"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f2"",""type"": ""int""}]}", - false)] + false, TestName = "TestRecordAliasesResolution5")] [TestCase(6,@"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f3"",""type"": ""int"", ""aliases"":[""f2""]}]}", @"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f2"",""type"": ""int""}]}", - true)] + true, TestName = "TestRecordAliasesResolution6")] [TestCase(7,@"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f3"",""type"": ""int"", ""aliases"":[""f4"",""f5""]}]}", @"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"":""long"" }, {""name"":""f2"",""type"": ""int""}]}", - false)] + false, TestName = "TestRecordAliasesResolution7")] [TestCase(8,@"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"": {""type"":""enum"", ""name"":""Symbol"", ""symbols"":[""A""] }}]}", @"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"": {""type"":""enum"", ""name"":""NewSymbol"", ""symbols"":[""A""] }}]}", - false)] + false, TestName = "TestRecordAliasesResolution8")] [TestCase(9,@"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"": {""type"":""enum"", ""name"":""Symbol"", ""aliases"":[""NewSymbol""], ""symbols"":[""A""] }}]}", @"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"": {""type"":""enum"", ""name"":""NewSymbol"", ""symbols"":[""A""] }}]}", - true)] + true, TestName = "TestRecordAliasesResolution9")] [TestCase(10,@"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"": {""type"":""enum"", ""name"":""Symbol"", ""aliases"":[""DiffSymbol""], ""symbols"":[""A""] }}]}", @"{""type"":""record"",""name"":""Rec"", ""fields"":[{""name"":""f1"",""type"": {""type"":""enum"", ""name"":""NewSymbol"", ""symbols"":[""A""] }}]}", - false)] + false, TestName = "TestRecordAliasesResolution10")] [TestCase(11,@"{""type"":""record"",""name"":""Rec"",""aliases"":[""NewRec""], ""fields"":[{""name"":""f2"",""aliases"":[""f1""],""type"": {""type"":""enum"", ""name"":""Symbol"", ""aliases"":[""NewSymbol""], ""symbols"":[""A""] }}, {""name"":""f3"",""aliases"":[""f4""],""type"": {""type"":""fixed"", ""name"":""Fixed"", ""aliases"":[""NewFixed""], ""size"": 1 }} @@ -209,7 +209,7 @@ public void TestFixedAliasesResolution(string reader, string writer, bool canrea ""fields"":[{""name"":""f1"",""type"": {""type"":""enum"", ""name"":""NewSymbol"", ""symbols"":[""A""] }}, {""name"":""f4"",""type"": {""type"":""fixed"", ""name"":""NewFixed"", ""size"": 1 }} ]}", - true)] + true, TestName = "TestRecordAliasesResolution11")] [TestCase(12,@"{""type"":""record"",""name"":""Rec"",""aliases"":[""NewRec""], ""fields"":[{""name"":""f2"",""aliases"":[""f1""],""type"": {""type"":""enum"", ""name"":""Symbol"", ""aliases"":[""NewSymbol""], ""symbols"":[""A""] }}, {""name"":""f3"",""aliases"":[""f4""],""type"": {""type"":""fixed"", ""name"":""Fixed"", ""aliases"":[""NewFixed""], ""size"":1 }} @@ -218,7 +218,7 @@ public void TestFixedAliasesResolution(string reader, string writer, bool canrea ""fields"":[{""name"":""f1"",""type"": {""type"":""enum"", ""name"":""NewSymbol"", ""symbols"":[""A"",""B""] }}, {""name"":""f4"",""type"": {""type"":""fixed"", ""name"":""NewFixed"", ""size"":1 }} ]}", - true)] + true, TestName = "TestRecordAliasesResolution12")] public void TestRecordAliasesResolution(int testid, string reader, string writer, bool canread) { diff --git a/lang/csharp/src/apache/test/Schema/SchemaNormalizationTests.cs b/lang/csharp/src/apache/test/Schema/SchemaNormalizationTests.cs index c3b0cd1ad..eb24dd13b 100644 --- a/lang/csharp/src/apache/test/Schema/SchemaNormalizationTests.cs +++ b/lang/csharp/src/apache/test/Schema/SchemaNormalizationTests.cs @@ -1,4 +1,4 @@ -/** +/** * 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 @@ -50,7 +50,9 @@ public void FingerprintTest(string input, string expectedOutput) private static List<object[]> ProvideFingerprintTestCases() { - using (StreamReader reader = new StreamReader("../../../../../share/test/data/schema-tests.txt")) + var dir = Path.GetDirectoryName(new Uri(typeof(SchemaNormalizationTests).Assembly.CodeBase).LocalPath); + var testsPath = Path.Combine(dir, "../../../../../share/test/data/schema-tests.txt"); + using (StreamReader reader = new StreamReader(testsPath)) { return CaseFinder.Find(reader, "fingerprint", new List<object[]>()); } @@ -58,7 +60,9 @@ private static List<object[]> ProvideFingerprintTestCases() private static List<object[]> ProvideCanonicalTestCases() { - using (StreamReader reader = new StreamReader("../../../../../share/test/data/schema-tests.txt")) + var dir = Path.GetDirectoryName(new Uri(typeof(SchemaNormalizationTests).Assembly.CodeBase).LocalPath); + var testsPath = Path.Combine(dir, "../../../../../share/test/data/schema-tests.txt"); + using (StreamReader reader = new StreamReader(testsPath)) { return CaseFinder.Find(reader, "canonical", new List<object[]>()); } diff --git a/lang/csharp/src/apache/test/Schema/SchemaTests.cs b/lang/csharp/src/apache/test/Schema/SchemaTests.cs index 7931d405b..5023f3826 100644 --- a/lang/csharp/src/apache/test/Schema/SchemaTests.cs +++ b/lang/csharp/src/apache/test/Schema/SchemaTests.cs @@ -64,22 +64,22 @@ public class SchemaTests "\"fields\":[{\"name\":\"value\",\"type\":\"long\"},{\"name\":\"next\",\"type\":[\"LongList\",\"null\"]}]}")] // Recursive. [TestCase("{\"type\":\"record\",\"name\":\"LongList\"," + "\"fields\":[{\"name\":\"value\",\"type\":\"long\"},{\"name\":\"next\",\"type\":[\"LongListA\",\"null\"]}]}", - Description = "Unknown name", ExpectedException = typeof(SchemaParseException))] + typeof(SchemaParseException), Description = "Unknown name")] [TestCase("{\"type\":\"record\",\"name\":\"LongList\"}", - Description = "No fields", ExpectedException = typeof(SchemaParseException))] + typeof(SchemaParseException), Description = "No fields")] [TestCase("{\"type\":\"record\",\"name\":\"LongList\", \"fields\": \"hi\"}", - Description = "Fields not an array", ExpectedException = typeof(SchemaParseException))] + typeof(SchemaParseException), Description = "Fields not an array")] // Enum [TestCase("{\"type\": \"enum\", \"name\": \"Test\", \"symbols\": [\"A\", \"B\"]}")] [TestCase("{\"type\": \"enum\", \"name\": \"Status\", \"symbols\": \"Normal Caution Critical\"}", - Description = "Symbols not an array", ExpectedException = typeof(SchemaParseException))] + typeof(SchemaParseException), Description = "Symbols not an array")] [TestCase("{\"type\": \"enum\", \"name\": [ 0, 1, 1, 2, 3, 5, 8 ], \"symbols\": [\"Golden\", \"Mean\"]}", - Description = "Name not a string", ExpectedException = typeof(SchemaParseException))] + typeof(SchemaParseException), Description = "Name not a string")] [TestCase("{\"type\": \"enum\", \"symbols\" : [\"I\", \"will\", \"fail\", \"no\", \"name\"]}", - Description = "No name", ExpectedException = typeof(SchemaParseException))] + typeof(SchemaParseException), Description = "No name")] [TestCase("{\"type\": \"enum\", \"name\": \"Test\", \"symbols\" : [\"AA\", \"AA\"]}", - Description = "Duplicate symbol", ExpectedException = typeof(SchemaParseException))] + typeof(SchemaParseException), Description = "Duplicate symbol")] // Array [TestCase("{\"type\": \"array\", \"items\": \"long\"}")] @@ -92,22 +92,27 @@ public class SchemaTests // Union [TestCase("[\"string\", \"null\", \"long\"]")] [TestCase("[\"string\", \"long\", \"long\"]", - Description = "Duplicate type", ExpectedException = typeof(SchemaParseException))] + typeof(SchemaParseException), Description = "Duplicate type")] [TestCase("[{\"type\": \"array\", \"items\": \"long\"}, {\"type\": \"array\", \"items\": \"string\"}]", - Description = "Duplicate type", ExpectedException = typeof(SchemaParseException))] + typeof(SchemaParseException), Description = "Duplicate type")] [TestCase("{\"type\":[\"string\", \"null\", \"long\"]}")] // Fixed [TestCase("{ \"type\": \"fixed\", \"name\": \"Test\", \"size\": 1}")] [TestCase("{\"type\": \"fixed\", \"name\": \"MyFixed\", \"namespace\": \"org.apache.hadoop.avro\", \"size\": 1}")] - [TestCase("{ \"type\": \"fixed\", \"name\": \"Test\", \"size\": 1}")] - [TestCase("{ \"type\": \"fixed\", \"name\": \"Test\", \"size\": 1}")] - [TestCase("{\"type\": \"fixed\", \"name\": \"Missing size\"}", ExpectedException = typeof(SchemaParseException))] + [TestCase("{\"type\": \"fixed\", \"name\": \"Missing size\"}", typeof(SchemaParseException))] [TestCase("{\"type\": \"fixed\", \"size\": 314}", - Description = "No name", ExpectedException = typeof(SchemaParseException))] - public void TestBasic(string s) + typeof(SchemaParseException), Description = "No name")] + public void TestBasic(string s, Type expectedExceptionType = null) { - Schema.Parse(s); + if (expectedExceptionType != null) + { + Assert.Throws(expectedExceptionType, () => { Schema.Parse(s); }); + } + else + { + Schema.Parse(s); + } } [TestCase("null", Schema.Type.Null)] @@ -265,7 +270,7 @@ public void TestFixed(string s, int size) testToString(sc); } - [TestCase("a", "o.a.h", Result = "o.a.h.a")] + [TestCase("a", "o.a.h", ExpectedResult = "o.a.h.a")] public string testFullname(string s1, string s2) { var name = new SchemaName(s1, s2, null); diff --git a/lang/csharp/src/apache/test/Specific/SpecificTests.cs b/lang/csharp/src/apache/test/Specific/SpecificTests.cs index a39168d13..8318ab571 100644 --- a/lang/csharp/src/apache/test/Specific/SpecificTests.cs +++ b/lang/csharp/src/apache/test/Specific/SpecificTests.cs @@ -1,4 +1,4 @@ -/** +/** * 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 @@ -157,8 +157,7 @@ class SpecificTests myArray3.Add(o1); myArray3.Add(o2); -"} -)] +"}, TestName = "TestSpecific")] public void TestSpecific(string str, object[] result) { if(compres == null) @@ -191,7 +190,7 @@ public void TestSpecific(string str, object[] result) // compile var comparam = new CompilerParameters(new string[] { "mscorlib.dll" }); comparam.ReferencedAssemblies.Add("System.dll"); - comparam.ReferencedAssemblies.Add("Avro.dll"); + comparam.ReferencedAssemblies.Add(Path.Combine(TestContext.CurrentContext.TestDirectory, "Avro.dll")); comparam.GenerateInMemory = true; var ccp = new Microsoft.CSharp.CSharpCodeProvider(); var units = new CodeCompileUnit[] { compileUnit }; @@ -375,4 +374,4 @@ public void Put(int fieldPos, object fieldValue) enumType = (EnumType)fieldValue; } } -} \ No newline at end of file +} diff --git a/lang/csharp/src/apache/test/Utils/CaseFinderTests.cs b/lang/csharp/src/apache/test/Utils/CaseFinderTests.cs index 1257863af..7b460969c 100644 --- a/lang/csharp/src/apache/test/Utils/CaseFinderTests.cs +++ b/lang/csharp/src/apache/test/Utils/CaseFinderTests.cs @@ -1,4 +1,4 @@ -/** +/** * 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 @@ -72,7 +72,7 @@ public void TestOutput(string input, string label, List<object[]> expectedOutput Assert.True(Eq(result, expectedOutput), Pr(result)); } - private List<Object[]> OutputTestCases() + private static List<Object[]> OutputTestCases() { List<Object[]> result = new List<Object[]>(); result.Add(new Object[] { "", "foo", new List<object[]> { } }); @@ -82,7 +82,6 @@ private List<Object[]> OutputTestCases() result.Add(new Object[] { "<<INPUT a\r<<OUTPUT b", "OUTPUT", new List<object[]> { new object[] { "a", "b" } } }); result.Add(new Object[] { "// This is a test\n<<INPUT a\n\n\n<<OUTPUT b", "OUTPUT", new List<object[]> { new object[] { "a", "b" } } }); result.Add(new Object[] { "<<INPUT a\n<<OUTPUT\nb\nOUTPUT", "OUTPUT", new List<object[]> { new object[] { "a", "b" } } }); - result.Add(new Object[] { "<<INPUT a\n<<OUTPUT\nb\nOUTPUT", "OUTPUT", new List<object[]> { new object[] { "a", "b" } } }); result.Add(new Object[] { "<<INPUT a\n<<OUTPUT\nb\n\nOUTPUT", "OUTPUT", new List<object[]> { new object[] { "a", "b\n" } } }); result.Add(new Object[] { "<<INPUT a\n<<OUTPUT\n\n b \n\nOUTPUT", "OUTPUT", new List<object[]> { new object[] { "a", "\n b \n" } } }); result.Add(new Object[] { "<<INPUT a\n<<O b\n<<INPUT c\n<<O d", "O", new List<object[]> { new object[] { "a", "b" }, new object[] { "c", "d" } } }); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Upgrade C# Unit Tests to NUnit 3.x > ---------------------------------- > > Key: AVRO-2161 > URL: https://issues.apache.org/jira/browse/AVRO-2161 > Project: Avro > Issue Type: Improvement > Components: csharp > Affects Versions: 1.8.2 > Reporter: Brian Lachniet > Priority: Major > > Before we can upgrade the C# project to .NET Core (AVRO-2112), we must first > upgrade our dependencies to versions that also run on .NET Core. NUnit is one > of the dependencies that we must upgrade. > NUnit 3.x will [run on .NET > Core|https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard]. There > many changes we must make in the [migration from NUnit 2.x to > 3.x|https://github.com/nunit/docs/wiki/Breaking-Changes#nunit-30]. > Since this is more than a simple update to a new version of the library, I > believe we should tackle this separate from other big migration tasks, like > the migration to .NET Core. -- This message was sent by Atlassian JIRA (v7.6.3#76005)