Skip to content

Commit

Permalink
Add E2E test case, add break in ResolveProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhg committed Nov 4, 2021
1 parent e0c5245 commit fa6e898
Show file tree
Hide file tree
Showing 5 changed files with 472 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/Microsoft.AspNetCore.OData/Edm/EdmModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public static IEdmProperty ResolveProperty(this IEdmStructuredType structuredTyp
else if (edmProperty != null)
{
ambiguous = true;
break;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//-----------------------------------------------------------------------------
// <copyright file="DefaultODataBatchHandlerController.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation and Contributors. All rights reserved.
// See License.txt in the project root for license information.
// </copyright>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.AspNetCore.OData.Routing.Controllers;

namespace Microsoft.AspNetCore.OData.E2E.Tests.Batch
{
public class DefaultBatchCustomersController : ODataController
{
private static IList<DefaultBatchCustomer> _customers = Enumerable.Range(0, 10).Select(i =>
new DefaultBatchCustomer
{
Id = i,
Name = string.Format("Name {0}", i)
}).ToList();

public IActionResult Get(int key)
{
DefaultBatchCustomer customers = _customers.FirstOrDefault(c => c.Id == key);
if (customers == null)
{
return BadRequest();
}

return Ok(customers);
}

[EnableQuery]
public IQueryable<DefaultBatchCustomer> OddCustomers()
{
return _customers.Where(x => x.Id % 2 == 1).AsQueryable();
}

public IActionResult Post([FromBody] DefaultBatchCustomer customer)
{
_customers.Add(customer);
return Created(customer);
}

public Task CreateRef([FromODataUri] int key, string navigationProperty, [FromBody] Uri link)
{
return Task.FromResult(StatusCode(StatusCodes.Status204NoContent));
}
}

public class DefaultBatchOrdersController : ODataController
{
public DefaultBatchOrdersController()
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//-----------------------------------------------------------------------------
// <copyright file="DefaultODataBatchHandlerModel.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation and Contributors. All rights reserved.
// See License.txt in the project root for license information.
// </copyright>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;

namespace Microsoft.AspNetCore.OData.E2E.Tests.Batch
{
public class DefaultBatchCustomer
{
public int Id { get; set; }

public string Name { get; set; }

public IList<DefaultBatchOrder> Orders { get; set; }
}

public class DefaultBatchOrder
{
public int Id { get; set; }

public DateTimeOffset PurchaseDate { get; set; }
}
}
Loading

0 comments on commit fa6e898

Please sign in to comment.