2017-11-15 00:40:27 +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;
|
2018-08-08 19:18:01 +02:00
|
|
|
|
using Microsoft.OpenApi.OData.Edm;
|
2017-11-22 03:32:29 +01:00
|
|
|
|
using Microsoft.OpenApi.OData.Tests;
|
2017-11-15 00:40:27 +01:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
2017-11-22 03:32:29 +01:00
|
|
|
|
namespace Microsoft.OpenApi.OData.Generator.Tests
|
2017-11-15 00:40:27 +01:00
|
|
|
|
{
|
2017-11-22 04:44:38 +01:00
|
|
|
|
public class OpenApiServerGeneratorTest
|
2017-11-15 00:40:27 +01:00
|
|
|
|
{
|
|
|
|
|
[Fact]
|
2017-11-22 04:44:38 +01:00
|
|
|
|
public void CreateServersThrowArgumentNullContext()
|
2017-11-15 00:40:27 +01:00
|
|
|
|
{
|
|
|
|
|
// Arrange
|
2017-11-22 04:44:38 +01:00
|
|
|
|
ODataContext context = null;
|
2017-11-15 00:40:27 +01:00
|
|
|
|
|
|
|
|
|
// Act & Assert
|
2017-11-22 04:44:38 +01:00
|
|
|
|
Assert.Throws<ArgumentNullException>("context", () => context.CreateServers());
|
2017-11-22 03:32:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2017-11-22 04:44:38 +01:00
|
|
|
|
public void CreateServersReturnsModel()
|
2017-11-22 03:32:29 +01:00
|
|
|
|
{
|
|
|
|
|
// Arrange
|
2017-11-22 04:44:38 +01:00
|
|
|
|
ODataContext context = new ODataContext(EdmModelHelper.BasicEdmModel);
|
2017-11-15 00:40:27 +01:00
|
|
|
|
|
2017-11-22 04:44:38 +01:00
|
|
|
|
// Act
|
|
|
|
|
var servers = context.CreateServers();
|
2017-11-15 00:40:27 +01:00
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.NotNull(servers);
|
|
|
|
|
var server = Assert.Single(servers);
|
|
|
|
|
Assert.Equal("http://localhost", server.Url);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|