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
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public interface IOrderQueries
|
||||
{
|
||||
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))
|
||||
{
|
||||
@ -58,7 +58,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<dynamic> GetCardTypesAsync()
|
||||
public async Task<IEnumerable<dynamic>> GetCardTypesAsync()
|
||||
{
|
||||
using (var connection = new SqlConnection(_connectionString))
|
||||
{
|
||||
|
@ -68,8 +68,9 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetOrders()
|
||||
{
|
||||
var orders = await _orderQueries
|
||||
.GetOrdersAsync();
|
||||
var orderTask = _orderQueries.GetOrdersAsync();
|
||||
|
||||
var orders = await orderTask;
|
||||
|
||||
return Ok(orders);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using Microsoft.eShopOnContainers.Services.Ordering.API.Controllers;
|
||||
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services;
|
||||
using Moq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
@ -59,7 +60,7 @@ namespace UnitTest.Ordering.Application
|
||||
public async Task Get_orders_success()
|
||||
{
|
||||
//Arrange
|
||||
var fakeDynamicResult = new Object();
|
||||
var fakeDynamicResult = Enumerable.Empty<object>();
|
||||
_orderQueriesMock.Setup(x => x.GetOrdersAsync())
|
||||
.Returns(Task.FromResult(fakeDynamicResult));
|
||||
|
||||
@ -92,7 +93,7 @@ namespace UnitTest.Ordering.Application
|
||||
public async Task Get_cardTypes_success()
|
||||
{
|
||||
//Arrange
|
||||
var fakeDynamicResult = new Object();
|
||||
var fakeDynamicResult = Enumerable.Empty<object>();
|
||||
_orderQueriesMock.Setup(x => x.GetCardTypesAsync())
|
||||
.Returns(Task.FromResult(fakeDynamicResult));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user