using System; using System.Collections.Generic; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Models; using NUnit.Framework; namespace Parser.Tests { public class ResponseParserTests { [Test] public void ValidResponseParsingShouldHaveCorrectValues() { int statusCode = 200; string example = "example"; KeyValuePair openApiResponse = new KeyValuePair(statusCode.ToString(), new OpenApiResponse { Content = new Dictionary { { "text/plain", new OpenApiMediaType { Schema = new OpenApiSchema {Type = "string", Format = null}, Example = new OpenApiString(example) } } } }); Response response = ResponseParser.ParseResponse(openApiResponse); Assert.AreEqual(statusCode, response.StatusCode); Assert.AreEqual(example, response.Example); } [Test] public void InvalidResponseStatusCodeShouldThrowException() { KeyValuePair openApiResponse = new KeyValuePair("invalid", new OpenApiResponse()); Assert.Throws(() => ResponseParser.ParseResponse(openApiResponse)); } } }