Merge pull request #181 from BillWagner/use-IEnumerable-dynamic
Use IEnumerable<dynamic> instead of dynamic for collections
This commit is contained in:
commit
3e5d38dae1
@ -1,13 +1,14 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries
|
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries
|
||||||
{
|
{
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public interface IOrderQueries
|
public interface IOrderQueries
|
||||||
{
|
{
|
||||||
Task<dynamic> GetOrderAsync(int id);
|
Task<dynamic> GetOrderAsync(int id);
|
||||||
|
|
||||||
Task<dynamic> GetOrdersAsync();
|
Task<IEnumerable<dynamic>> GetOrdersAsync();
|
||||||
|
|
||||||
Task<dynamic> GetCardTypesAsync();
|
Task<IEnumerable<dynamic>> GetCardTypesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<dynamic> GetOrdersAsync()
|
public async Task<IEnumerable<dynamic>> GetOrdersAsync()
|
||||||
{
|
{
|
||||||
using (var connection = new SqlConnection(_connectionString))
|
using (var connection = new SqlConnection(_connectionString))
|
||||||
{
|
{
|
||||||
@ -58,7 +58,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<dynamic> GetCardTypesAsync()
|
public async Task<IEnumerable<dynamic>> GetCardTypesAsync()
|
||||||
{
|
{
|
||||||
using (var connection = new SqlConnection(_connectionString))
|
using (var connection = new SqlConnection(_connectionString))
|
||||||
{
|
{
|
||||||
|
@ -68,8 +68,9 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> GetOrders()
|
public async Task<IActionResult> GetOrders()
|
||||||
{
|
{
|
||||||
var orders = await _orderQueries
|
var orderTask = _orderQueries.GetOrdersAsync();
|
||||||
.GetOrdersAsync();
|
|
||||||
|
var orders = await orderTask;
|
||||||
|
|
||||||
return Ok(orders);
|
return Ok(orders);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using Microsoft.eShopOnContainers.Services.Ordering.API.Controllers;
|
|||||||
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services;
|
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services;
|
||||||
using Moq;
|
using Moq;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ namespace UnitTest.Ordering.Application
|
|||||||
public async Task Get_orders_success()
|
public async Task Get_orders_success()
|
||||||
{
|
{
|
||||||
//Arrange
|
//Arrange
|
||||||
var fakeDynamicResult = new Object();
|
var fakeDynamicResult = Enumerable.Empty<object>();
|
||||||
_orderQueriesMock.Setup(x => x.GetOrdersAsync())
|
_orderQueriesMock.Setup(x => x.GetOrdersAsync())
|
||||||
.Returns(Task.FromResult(fakeDynamicResult));
|
.Returns(Task.FromResult(fakeDynamicResult));
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ namespace UnitTest.Ordering.Application
|
|||||||
public async Task Get_cardTypes_success()
|
public async Task Get_cardTypes_success()
|
||||||
{
|
{
|
||||||
//Arrange
|
//Arrange
|
||||||
var fakeDynamicResult = new Object();
|
var fakeDynamicResult = Enumerable.Empty<object>();
|
||||||
_orderQueriesMock.Setup(x => x.GetCardTypesAsync())
|
_orderQueriesMock.Setup(x => x.GetCardTypesAsync())
|
||||||
.Returns(Task.FromResult(fakeDynamicResult));
|
.Returns(Task.FromResult(fakeDynamicResult));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user