-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add E2E test case, add break in ResolveProperty
- Loading branch information
Showing
5 changed files
with
472 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
test/Microsoft.AspNetCore.OData.E2E.Tests/Batch/DefaultODataBatchHandlerController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
{ | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
test/Microsoft.AspNetCore.OData.E2E.Tests/Batch/DefaultODataBatchHandlerModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
Oops, something went wrong.