OpenAPI.NET.OData/test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiTagGeneratorTests.cs

71 lines
2 KiB
C#
Raw Normal View History

2017-11-14 23:59:06 +01:00
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
using System;
using System.Linq;
2017-11-22 03:32:29 +01:00
using Microsoft.OpenApi.OData.Tests;
2017-11-14 23:59:06 +01:00
using Xunit;
2017-11-22 03:32:29 +01:00
namespace Microsoft.OpenApi.OData.Generator.Tests
2017-11-14 23:59:06 +01:00
{
2017-11-22 03:32:29 +01:00
public class OpenApiTagGeneratorTest
2017-11-14 23:59:06 +01:00
{
[Fact]
2017-11-22 04:44:38 +01:00
public void CreateTagsThrowArgumentNullContext()
2017-11-14 23:59:06 +01:00
{
// Arrange
2017-11-22 04:44:38 +01:00
ODataContext context = null;
2017-11-14 23:59:06 +01:00
// Act & Assert
2017-11-22 04:44:38 +01:00
Assert.Throws<ArgumentNullException>("context", () => context.CreateTags());
2017-11-22 03:32:29 +01:00
}
[Fact]
public void CreateTagsReturnsEmptyTagsForEmptyModel()
2017-11-22 03:32:29 +01:00
{
// Arrange
2017-11-22 04:44:38 +01:00
ODataContext context = new ODataContext(EdmModelHelper.EmptyModel);
2017-11-14 23:59:06 +01:00
2017-11-22 04:44:38 +01:00
// Act
var tags = context.CreateTags();
2017-11-14 23:59:06 +01:00
// Assert
2017-11-27 20:12:24 +01:00
Assert.NotNull(tags);
Assert.Empty(tags);
2017-11-14 23:59:06 +01:00
}
[Fact]
public void CreateTagsReturnsTagsForBasicModel()
{
2017-11-22 04:44:38 +01:00
// Arrange
ODataContext context = new ODataContext(EdmModelHelper.BasicEdmModel);
// Act
var tags = context.CreateTags();
2017-11-14 23:59:06 +01:00
// Assert
Assert.NotNull(tags);
2017-11-16 20:19:47 +01:00
Assert.Equal(4, tags.Count);
Assert.Equal(new[] { "People", "City", "CountryOrRegion", "Me" }, tags.Select(t => t.Name));
2017-11-14 23:59:06 +01:00
}
[Fact]
public void CreateTagsReturnsTagsForTripModel()
{
2017-11-22 04:44:38 +01:00
// Arrange
ODataContext context = new ODataContext(EdmModelHelper.TripServiceModel);
// Act
var tags = context.CreateTags();
2017-11-14 23:59:06 +01:00
// Assert
Assert.NotNull(tags);
2017-11-22 04:44:38 +01:00
Assert.Equal(6, tags.Count);
Assert.Equal(new[] { "People", "Airlines", "Airports", "NewComePeople", "Me", "ResetDataSource" },
2017-11-14 23:59:06 +01:00
tags.Select(t => t.Name));
}
}
}