45 lines
1.7 KiB
C#
45 lines
1.7 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.OData.Edm;
|
|
using Microsoft.OpenApi.OData.Tests;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.OpenApi.OData.Operation.Tests
|
|
{
|
|
public class SingletonPatchOperationHandlerTests
|
|
{
|
|
private SingletonPatchOperationHandler _operationHandler = new SingletonPatchOperationHandler();
|
|
|
|
[Fact]
|
|
public void CreateSingletonPatchOperationReturnsCorrectOperation()
|
|
{
|
|
// Arrange
|
|
IEdmModel model = EdmModelHelper.BasicEdmModel;
|
|
IEdmSingleton singleton = model.EntityContainer.FindSingleton("Me");
|
|
ODataContext context = new ODataContext(model);
|
|
ODataPath path = new ODataPath(new ODataNavigationSourceSegment(singleton));
|
|
|
|
// Act
|
|
var patch = _operationHandler.CreateOperation(context, path);
|
|
|
|
// Assert
|
|
Assert.NotNull(patch);
|
|
Assert.Equal("Update Me", patch.Summary);
|
|
Assert.NotNull(patch.Tags);
|
|
var tag = Assert.Single(patch.Tags);
|
|
Assert.Equal("Me.Person", tag.Name);
|
|
|
|
Assert.Empty(patch.Parameters);
|
|
Assert.NotNull(patch.RequestBody);
|
|
|
|
Assert.NotNull(patch.Responses);
|
|
Assert.Equal(2, patch.Responses.Count);
|
|
Assert.Equal(new[] { "204", "default" }, patch.Responses.Select(r => r.Key));
|
|
}
|
|
}
|
|
}
|