// ------------------------------------------------------------ // 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 EntityDeleteOperationHandlerTests { private EntityDeleteOperationHandler _operationHandler = new EntityDeleteOperationHandler(); [Fact] public void CreateEntityDeleteOperationReturnsCorrectOperation() { // Arrange IEdmModel model = EdmModelHelper.BasicEdmModel; IEdmEntitySet entitySet = model.EntityContainer.FindEntitySet("People"); ODataContext context = new ODataContext(model); ODataPath path = new ODataPath(new ODataNavigationSourceSegment(entitySet), new ODataKeySegment(entitySet.EntityType())); // Act var delete = _operationHandler.CreateOperation(context, path); // Assert Assert.NotNull(delete); Assert.Equal("Delete entity from People", delete.Summary); Assert.NotNull(delete.Tags); var tag = Assert.Single(delete.Tags); Assert.Equal("People.Person", tag.Name); Assert.NotNull(delete.Parameters); Assert.Equal(2, delete.Parameters.Count); Assert.Null(delete.RequestBody); Assert.NotNull(delete.Responses); Assert.Equal(2, delete.Responses.Count); Assert.Equal(new[] { "204", "default" }, delete.Responses.Select(r => r.Key)); } } }