42 lines
1.6 KiB
C#
42 lines
1.6 KiB
C#
// ------------------------------------------------------------
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
|
|
// ------------------------------------------------------------
|
|
|
|
using System.Linq;
|
|
using Microsoft.OData.Edm;
|
|
using Microsoft.OpenApi.Models;
|
|
using Microsoft.OpenApi.OData.Edm;
|
|
using Microsoft.OpenApi.OData.Tests;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.OpenApi.OData.PathItem.Tests
|
|
{
|
|
public class EntityPathItemGeneratorTests
|
|
{
|
|
private EntityPathItemHandler _pathItemHandler = new EntityPathItemHandler();
|
|
|
|
[Fact]
|
|
public void CreateEntityPathItemReturnsCorrectPathItem()
|
|
{
|
|
// Arrange
|
|
IEdmModel model = EdmModelHelper.BasicEdmModel;
|
|
ODataContext context = new ODataContext(model);
|
|
IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("People");
|
|
Assert.NotNull(entitySet); // guard
|
|
ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType()));
|
|
|
|
// Act
|
|
var pathItem = _pathItemHandler.CreatePathItem(context, path);
|
|
|
|
// Assert
|
|
Assert.NotNull(pathItem);
|
|
|
|
Assert.NotNull(pathItem.Operations);
|
|
Assert.NotEmpty(pathItem.Operations);
|
|
Assert.Equal(3, pathItem.Operations.Count);
|
|
Assert.Equal(new OperationType[] { OperationType.Get, OperationType.Patch, OperationType.Delete },
|
|
pathItem.Operations.Select(o => o.Key));
|
|
}
|
|
}
|
|
}
|