Skip to content

Commit

Permalink
Add Task Azure#3 Test Code
Browse files Browse the repository at this point in the history
  • Loading branch information
CistusF committed Apr 10, 2022
1 parent b217f20 commit 2930703
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;

using FluentAssertions;

using Microsoft.OpenApi.Models;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Newtonsoft.Json;

namespace Microsoft.Azure.WebJobs.Extensions.OpenApi.Document.Tests.OpenApiInfo
{
[TestClass]
[TestCategory(Constants.TestCategory)]
public class OpenApiConfigurationOptionsTests
{
private static HttpClient http = new HttpClient();

private string _json;
private OpenApiDocument _doc;

[TestInitialize]
public async Task Init()
{
this._json = await http.GetStringAsync(Constants.OpenApiDocEndpoint).ConfigureAwait(false);
this._doc = JsonConvert.DeserializeObject<OpenApiDocument>(this._json);
}

[TestMethod]
public void Given_OpenApiDocument_When_ForceHttps_Given_Then_It_Should_Return_Https()
{
var servers = this._doc.Servers;

servers[0].Url.Should().Be("https://localhost:7071/api");
}

[TestMethod]
public void Given_OpenApiDocument_Then_It_Should_Return_Title()
{
this._doc.Info.Title.Should().Be(OpenApiInfoConfigs.DocTitle);
}

[TestMethod]
public void Given_OpenApiDocument_Then_It_Should_Return_Description()
{
this._doc.Info.Description.Should().Be(OpenApiInfoConfigs.DocDescription);
}

[TestMethod]
public void Given_OpenApiDocument_Then_It_Should_Return_TermsOfService()
{
this._doc.Info.TermsOfService.AbsoluteUri.Should().Be(OpenApiInfoConfigs.TermsOfService);
}

[TestMethod]
public void Given_OpenApiDocument_Then_It_Should_Return_ContactName()
{
var contact = this._doc.Info.Contact;

contact.Name.Should().Be(OpenApiInfoConfigs.ContactName);
}

[TestMethod]
public void Given_OpenApiDocument_Then_It_Should_Return_ContactEmail()
{
var contact = this._doc.Info.Contact;

contact.Email.Should().Be(OpenApiInfoConfigs.ContactEmail);
}

[TestMethod]
public void Given_OpenApiDocument_Then_It_Should_Return_ContactUrl()
{
var contact = this._doc.Info.Contact;

contact.Url.AbsoluteUri.Should().Be(OpenApiInfoConfigs.ContactUrl);
}

[TestMethod]
public void Given_OpenApiDocument_Then_It_Should_Return_LicenseName()
{
var license = this._doc.Info.License;

license.Name.Should().Be(OpenApiInfoConfigs.LicenseName);
}

[TestMethod]
public void Given_OpenApiDocument_Then_It_Should_Return_LicenseUrl()
{
var license = this._doc.Info.License;

license.Url.AbsoluteUri.Should().Be(OpenApiInfoConfigs.LicenseUrl);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"OpenApi__ForceHttps": "true"
}
}

0 comments on commit 2930703

Please sign in to comment.