OpenAPI.NET.OData/test/Microsoft.OpenAPI.OData.Reader.Tests/Edm/ODataOperationImportSegmentTests.cs

71 lines
2.3 KiB
C#
Raw Normal View History

2018-08-08 19:18:01 +02: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 Microsoft.OData.Edm;
2018-08-08 19:18:01 +02:00
using Xunit;
namespace Microsoft.OpenApi.OData.Edm.Tests
{
public class ODataOperationImportSegmentTests
{
private IEdmOperationImport _operationImport;
2018-08-21 23:42:55 +02:00
public ODataOperationImportSegmentTests()
{
IEdmEntityContainer container = new EdmEntityContainer("NS", "default");
IEdmAction action = new EdmAction("NS", "MyAction", null);
_operationImport = new EdmActionImport(container, "MyAction", action);
}
[Fact]
public void CtorThrowArgumentNullOperationImport()
{
// Arrange & Act & Assert
Assert.Throws<ArgumentNullException>("operationImport", () => new ODataOperationImportSegment(operationImport: null));
}
[Fact]
public void CtorSetOperationImportProperty()
{
// Arrange & Act
var segment = new ODataOperationImportSegment(_operationImport);
// Assert
Assert.Same(_operationImport, segment.OperationImport);
}
[Fact]
public void GetEntityTypeThrowsNotImplementedException()
{
// Arrange & Act
var segment = new ODataOperationImportSegment(_operationImport);
// Assert
Assert.Throws<NotImplementedException>(() => segment.EntityType);
}
[Fact]
2018-08-21 23:42:55 +02:00
public void KindPropertyReturnsOperationImportEnumMember()
{
// Arrange & Act
var segment = new ODataOperationImportSegment(_operationImport);
// Assert
2018-08-21 23:42:55 +02:00
Assert.Equal(ODataSegmentKind.OperationImport, segment.Kind);
}
[Fact]
2018-08-21 23:42:55 +02:00
public void GetPathItemNameReturnsCorrectOperationImportLiteral()
{
// Arrange & Act
var segment = new ODataOperationImportSegment(_operationImport);
// Assert
2018-08-21 23:42:55 +02:00
Assert.Equal("MyAction", segment.GetPathItemName(new OpenApiConvertSettings()));
}
2018-08-08 19:18:01 +02:00
}
}