forked from loafle/openapi-generator-original
add test cases for configuration
This commit is contained in:
@@ -31,12 +31,6 @@ namespace {{packageName}}.Client
|
||||
/// <value>The API client.</value>
|
||||
public ApiClient ApiClient = new ApiClient();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the base path.
|
||||
/// </summary>
|
||||
/// <value>The base path.</value>
|
||||
public String BasePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the username (HTTP basic authentication).
|
||||
/// </summary>
|
||||
|
||||
@@ -31,12 +31,6 @@ namespace IO.Swagger.Client
|
||||
/// <value>The API client.</value>
|
||||
public ApiClient ApiClient = new ApiClient();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the base path.
|
||||
/// </summary>
|
||||
/// <value>The base path.</value>
|
||||
public String BasePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the username (HTTP basic authentication).
|
||||
/// </summary>
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\User.cs" />
|
||||
<Compile Include="TestPet.cs" />
|
||||
<Compile Include="TestApiClient.cs" />
|
||||
<Compile Include="TestConfiguration.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using IO.Swagger.Client;
|
||||
using IO.Swagger.Api;
|
||||
using IO.Swagger.Model;
|
||||
|
||||
namespace SwaggerClient.TestConfiguration
|
||||
{
|
||||
public class TestConfiguration
|
||||
{
|
||||
[Test ()]
|
||||
public void TestAuthentication ()
|
||||
{
|
||||
Configuration c = new Configuration ();
|
||||
c.Username = "test_username";
|
||||
c.Password = "test_password";
|
||||
|
||||
c.ApiKey ["api_key_identifier"] = "1233456778889900";
|
||||
c.ApiKeyPrefix ["api_key_identifier"] = "PREFIX";
|
||||
Assert.AreEqual (c.GetApiKeyWithPrefix("api_key_identifier"), "PREFIX 1233456778889900");
|
||||
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestBasePath ()
|
||||
{
|
||||
PetApi p = new PetApi ("http://new-basepath.com");
|
||||
Assert.AreEqual (p.Configuration.ApiClient.BasePath, "http://new-basepath.com");
|
||||
Assert.AreSame (p.Configuration, Configuration.DefaultConfiguration);
|
||||
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestDefautlConfiguration ()
|
||||
{
|
||||
PetApi p1 = new PetApi ();
|
||||
PetApi p2 = new PetApi ();
|
||||
Assert.AreSame (p1.Configuration, p2.Configuration);
|
||||
// same as the default
|
||||
Assert.AreSame (p1.Configuration, Configuration.DefaultConfiguration);
|
||||
|
||||
Configuration c = new Configuration ();
|
||||
Assert.AreNotSame (c, p1.Configuration);
|
||||
|
||||
PetApi p3 = new PetApi (c);
|
||||
// same as c
|
||||
Assert.AreSame (p3.Configuration, c);
|
||||
// not same as default
|
||||
Assert.AreNotSame (p3.Configuration, p1.Configuration);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user