forked from loafle/openapi-generator-original
* [csharp] Fix apiPackage,modelPackage,excludeTests The apiPackage, modelPackage, and excludeTests values were not being populated correctly from external configs (passing -c filename to generator). This commit allows those properties to work correctly with the Csharp client generator. Previously the Api and Model namespaces were hard coded after additionalProperties for these were evaluated. The files which generate test files for models and api classes didn't honor the excludeTests option. * [csharp] Regenerate sample * [csharp] Fix modelPackage in README template
76 lines
2.1 KiB
Plaintext
76 lines
2.1 KiB
Plaintext
{{>partial_header}}
|
|
using System;
|
|
using System.IO;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using RestSharp;
|
|
using NUnit.Framework;
|
|
|
|
using {{packageName}}.Client;
|
|
using {{packageName}}.{{apiPackage}};
|
|
{{#hasImport}}using {{packageName}}.{{modelPackage}};
|
|
{{/hasImport}}
|
|
|
|
namespace {{packageName}}.Test
|
|
{
|
|
/// <summary>
|
|
/// Class for testing {{classname}}
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This file is automatically generated by Swagger Codegen.
|
|
/// Please update the test case below to test the API endpoint.
|
|
/// </remarks>
|
|
[TestFixture]
|
|
public class {{classname}}Tests
|
|
{
|
|
private {{classname}} instance;
|
|
|
|
/// <summary>
|
|
/// Setup before each unit test
|
|
/// </summary>
|
|
[SetUp]
|
|
public void Init()
|
|
{
|
|
instance = new {{classname}}();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Clean up after each unit test
|
|
/// </summary>
|
|
[TearDown]
|
|
public void Cleanup()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Test an instance of {{classname}}
|
|
/// </summary>
|
|
[Test]
|
|
public void {{operationId}}InstanceTest()
|
|
{
|
|
// TODO uncomment below to test 'IsInstanceOfType' {{classname}}
|
|
//Assert.IsInstanceOfType(typeof({{classname}}), instance, "instance is a {{classname}}");
|
|
}
|
|
|
|
{{#operations}}{{#operation}}
|
|
/// <summary>
|
|
/// Test {{operationId}}
|
|
/// </summary>
|
|
[Test]
|
|
public void {{operationId}}Test()
|
|
{
|
|
// TODO uncomment below to test the method and replace null with proper value
|
|
{{#allParams}}
|
|
//{{{dataType}}} {{paramName}} = null;
|
|
{{/allParams}}
|
|
//{{#returnType}}var response = {{/returnType}}instance.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
|
{{#returnType}}//Assert.IsInstanceOf<{{{returnType}}}> (response, "response is {{{returnType}}}");{{/returnType}}
|
|
}
|
|
{{/operation}}{{/operations}}
|
|
}
|
|
|
|
}
|