All Downloads are FREE. Search and download functionalities are using the official Maven repository.

csharp.libraries.generichost.api_test.mustache Maven / Gradle / Ivy

There is a newer version: 7.7.0
Show newest version
{{>partial_header}}
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;
using Microsoft.Extensions.DependencyInjection;
using {{packageName}}.{{apiPackage}};{{#hasImport}}
using {{packageName}}.{{modelPackage}};{{/hasImport}}


{{>testInstructions}}


namespace {{packageName}}.Test.{{apiPackage}}
{
    /// 
    ///  Class for testing {{classname}}
    /// 
    public sealed class {{classname}}Tests : ApiTestsBase
    {
        private readonly {{interfacePrefix}}{{classname}} _instance;

        public {{classname}}Tests(): base(Array.Empty())
        {
            _instance = _host.Services.GetRequiredService<{{interfacePrefix}}{{classname}}>();
        }
        {{#operations}}
        {{#operation}}

        /// 
        /// Test {{operationId}}
        /// 
        [Fact (Skip = "not implemented")]
        public async Task {{operationId}}AsyncTest()
        {
            {{#allParams}}
            {{^required}}Client.Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} = default{{nrt!}};
            {{/allParams}}
            {{#returnType}}
            var response = await _instance.{{operationId}}Async({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
            var model = response.{{#lambda.first}}{{#responses}}{{vendorExtensions.x-http-status}}  {{/responses}}{{/lambda.first}}();
            Assert.IsType<{{{.}}}>(model);
            {{/returnType}}
            {{^returnType}}
            await _instance.{{operationId}}Async({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
            {{/returnType}}
        }
        {{/operation}}
        {{/operations}}
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy