add mono script to nunit test csharp client

This commit is contained in:
wing328 2016-06-11 23:44:48 +08:00
parent 9102dce654
commit bc04ebed94
14 changed files with 92 additions and 24 deletions

1
.gitignore vendored
View File

@ -112,6 +112,7 @@ samples/client/petstore/csharp/SwaggerClient/bin
samples/client/petstore/csharp/SwaggerClient/obj/Debug/
samples/client/petstore/csharp/SwaggerClient/bin/Debug/
samples/client/petstore/csharp/SwaggerClient/packages
samples/client/petstore/csharp/SwaggerClient/TestResult.xml
# Python
*.pyc

View File

@ -238,6 +238,8 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
supportingFiles.add(new SupportingFile("compile.mustache", "", "build.bat"));
supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "build.sh"));
// shell script to run the nunit test
supportingFiles.add(new SupportingFile("mono_nunit_test.mustache", "", "mono_nunit_test.sh"));
// copy package.config to nuget's standard location for project-level installs
supportingFiles.add(new SupportingFile("packages.config.mustache", packageFolder + File.separator, "packages.config"));

View File

@ -61,12 +61,12 @@ namespace {{packageName}}.Test
[Test]
public void {{operationId}}Test()
{
// TODO: add unit test for the method '{{operationId}}'
// TODO uncomment below to test the method '{{operationId}}'
{{#allParams}}
{{{dataType}}} {{paramName}} = null; // TODO: replace null with proper value
//{{{dataType}}} {{paramName}} = null; // TODO: replace null with proper value
{{/allParams}}
{{#returnType}}var response = {{/returnType}}instance.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{#returnType}}Assert.IsInstanceOf<{{{returnType}}}> (response, "response is {{{returnType}}}");{{/returnType}}
//{{#returnType}}var response = {{/returnType}}instance.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{#returnType}}//Assert.IsInstanceOf<{{{returnType}}}> (response, "response is {{{returnType}}}");{{/returnType}}
}
{{/operation}}{{/operations}}
}

View File

@ -2,14 +2,19 @@
frameworkVersion={{targetFrameworkNuget}}
netfx=${frameworkVersion#net}
echo "[INFO] Target framework: ${frameworkVersion}"
echo "[INFO] Download nuget and packages"
wget -nc https://nuget.org/nuget.exe;
mozroots --import --sync
mono nuget.exe install src/{{packageName}}/packages.config -o packages;
mkdir -p bin;
echo "[INFO] Copy DLLs to the 'bin' folder"
cp packages/Newtonsoft.Json.8.0.2/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll;
cp packages/RestSharp.105.1.0/lib/{{targetFrameworkNuget}}/RestSharp.dll bin/RestSharp.dll;
echo "[INFO] Run 'mcs' to build bin/{{{packageName}}}.dll"
mcs -sdk:${netfx} -r:bin/Newtonsoft.Json.dll,\
bin/RestSharp.dll,\
System.Runtime.Serialization.dll \

View File

@ -33,7 +33,8 @@ namespace {{packageName}}.Test
[SetUp]
public void Init()
{
instance = new {{classname}}();
// TODO uncomment below to create an instance of {{classname}}
//instance = new {{classname}}();
}
/// <summary>
@ -51,7 +52,8 @@ namespace {{packageName}}.Test
[Test]
public void {{classname}}InstanceTest()
{
Assert.IsInstanceOf<{{classname}}> (instance, "instance is a {{classname}}");
// TODO uncomment below to test "IsInstanceOf" {{classname}}
//Assert.IsInstanceOf<{{classname}}> (instance, "variable 'instance' is a {{classname}}");
}
{{#vars}}
@ -61,7 +63,7 @@ namespace {{packageName}}.Test
[Test]
public void {{name}}Test()
{
// TODO: unit test for the property '{{name}}'
// TODO unit test for the property '{{name}}'
}
{{/vars}}

View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
wget -nc https://nuget.org/nuget.exe
mozroots --import --sync
echo "[INFO] remove bin/Debug/SwaggerClientTest.dll"
rm src/IO.Swagger.Test/bin/Debug/{{{packageName}}}.Test.dll 2> /dev/null
echo "[INFO] install NUnit runners via NuGet"
wget -nc https://nuget.org/nuget.exe
mozroots --import --sync
mono nuget.exe install src/{{{packageName}}}.Test/packages.config -o packages
echo "[INFO] Copy DLLs to the 'bin' folder"
# for project {{{packageName}}}
cp packages/Newtonsoft.Json.8.0.3/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll src/{{{packageName}}}/bin/Debug/Newtonsoft.Json.dll
cp packages/RestSharp.105.1.0/lib/{{targetFrameworkNuget}}/RestSharp.dll src/{{{packageName}}}/bin/Debug/RestSharp.dll
cp packages/NUnit.2.6.4/lib/nunit.framework.dll src/{{{packageName}}}/bin/Debug/nunit.framework.dll
# for project {{{packageName}}}.Test
cp packages/Newtonsoft.Json.8.0.3/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll src/{{{packageName}}}.Test/bin/Debug/Newtonsoft.Json.dll
cp packages/RestSharp.105.1.0/lib/{{targetFrameworkNuget}}/RestSharp.dll src/{{{packageName}}}.Test/bin/Debug/RestSharp.dll
cp packages/NUnit.2.6.4/lib/nunit.framework.dll src/{{{packageName}}}.Test/bin/Debug/nunit.framework.dll
echo "[INFO] Install NUnit runners via NuGet"
mono nuget.exe install NUnit.Runners -Version 2.6.4 -OutputDirectory packages
echo "[INFO] build the solution and run the unit test"
xbuild {{{packageName}}}.sln && \
mono ./packages/NUnit.Runners.2.6.4/tools/nunit-console.exe src/{{{packageName}}}.Test/bin/debug/{{{packageName}}}.Test.dll

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="RestSharp" version="105.1.0" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
</packages>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.3" targetFramework="{{targetFrameworkNuget}}" />
<package id="NUnit" version="2.6.4" targetFramework="{{targetFrameworkNuget}}" />
<package id="RestSharp" version="105.1.0" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
</packages>

View File

@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
VisualStudioVersion = 12.0.0.0
MinimumVisualStudioVersion = 10.0.0.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{EE727567-9CAF-4258-AA0E-FDF89487D7D6}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{7B057377-44BA-47A5-AC6B-70EEB6034E6F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger.Test", "src\IO.Swagger.Test\IO.Swagger.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
EndProject
@ -12,10 +12,10 @@ Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EE727567-9CAF-4258-AA0E-FDF89487D7D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE727567-9CAF-4258-AA0E-FDF89487D7D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE727567-9CAF-4258-AA0E-FDF89487D7D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE727567-9CAF-4258-AA0E-FDF89487D7D6}.Release|Any CPU.Build.0 = Release|Any CPU
{7B057377-44BA-47A5-AC6B-70EEB6034E6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B057377-44BA-47A5-AC6B-70EEB6034E6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B057377-44BA-47A5-AC6B-70EEB6034E6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B057377-44BA-47A5-AC6B-70EEB6034E6F}.Release|Any CPU.Build.0 = Release|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@ -6,7 +6,7 @@ This C# SDK is automatically generated by the [Swagger Codegen](https://github.c
- API version: 1.0.0
- SDK version: 1.0.0
- Build date: 2016-06-10T08:07:39.769-04:00
- Build date: 2016-06-11T23:10:58.942+08:00
- Build package: class io.swagger.codegen.languages.CSharpClientCodegen
## Frameworks supported
@ -138,6 +138,12 @@ Class | Method | HTTP request | Description
## Documentation for Authorization
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
### petstore_auth
- **Type**: OAuth
@ -147,9 +153,3 @@ Class | Method | HTTP request | Description
- write:pets: modify pets in your account
- read:pets: read your pets
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header

View File

@ -2,14 +2,19 @@
frameworkVersion=net45
netfx=${frameworkVersion#net}
echo "[INFO] Target framework: ${frameworkVersion}"
echo "[INFO] Download nuget and packages"
wget -nc https://nuget.org/nuget.exe;
mozroots --import --sync
mono nuget.exe install src/IO.Swagger/packages.config -o packages;
mkdir -p bin;
echo "[INFO] Copy DLLs to the 'bin' folder"
cp packages/Newtonsoft.Json.8.0.2/lib/net45/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll;
cp packages/RestSharp.105.1.0/lib/net45/RestSharp.dll bin/RestSharp.dll;
echo "[INFO] Run 'mcs' to build bin/IO.Swagger.dll"
mcs -sdk:${netfx} -r:bin/Newtonsoft.Json.dll,\
bin/RestSharp.dll,\
System.Runtime.Serialization.dll \

View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
wget -nc https://nuget.org/nuget.exe;
mozroots --import --sync
echo "[INFO] remove bin/Debug/SwaggerClientTest.dll"
rm src/IO.Swagger.Test/bin/Debug/IO.Swagger.Test.dll 2> /dev/null
echo "[INFO] install NUnit runners via NuGet"
wget -nc https://nuget.org/nuget.exe;
mozroots --import --sync
mono nuget.exe install src/IO.Swagger.Test/packages.config -o packages;
echo "[INFO] Copy DLLs to the 'bin' folder"
# for project IO.Swagger
cp packages/Newtonsoft.Json.8.0.2/lib/net45/Newtonsoft.Json.dll src/IO.Swagger/bin/Debug/Newtonsoft.Json.dll
cp packages/RestSharp.105.1.0/lib/net45/RestSharp.dll src/IO.Swagger/bin/Debug/RestSharp.dll
cp packages/NUnit.2.6.3/lib/nunit.framework.dll src/IO.Swagger/bin/Debug/nunit.framework.dll
# for project IO.Swagger.Test
cp packages/Newtonsoft.Json.8.0.2/lib/net45/Newtonsoft.Json.dll src/IO.Swagger.Test/bin/Debug/Newtonsoft.Json.dll
cp packages/RestSharp.105.1.0/lib/net45/RestSharp.dll src/IO.Swagger.Test/bin/Debug/RestSharp.dll
cp packages/NUnit.2.6.3/lib/nunit.framework.dll src/IO.Swagger.Test/bin/Debug/nunit.framework.dll
echo "[INFO] build the solution and run the unit test"
xbuild IO.Swagger.sln && \
mono ./testrunner/NUnit.Runners.2.6.4/tools/nunit-console.exe src/IO.Swagger.Test/bin/debug/IO.Swagger.Test.dll

View File

@ -86,7 +86,7 @@ limitations under the License.
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\IO.Swagger\IO.Swagger.csproj">
<Project>{EE727567-9CAF-4258-AA0E-FDF89487D7D6}</Project>
<Project>{7B057377-44BA-47A5-AC6B-70EEB6034E6F}</Project>
<Name>IO.Swagger</Name>
</ProjectReference>
</ItemGroup>

View File

@ -24,7 +24,7 @@ limitations under the License.
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EE727567-9CAF-4258-AA0E-FDF89487D7D6}</ProjectGuid>
<ProjectGuid>{7B057377-44BA-47A5-AC6B-70EEB6034E6F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Swagger Library</RootNamespace>