Browse Source

Merge pull request #181 from BillWagner/use-IEnumerable-dynamic

Use IEnumerable<dynamic> instead of dynamic for collections
pull/223/head
Cesar De la Torre 7 years ago
committed by GitHub
parent
commit
660e1932a3
4 changed files with 11 additions and 8 deletions
  1. +3
    -2
      src/Services/Ordering/Ordering.API/Application/Queries/IOrderQueries.cs
  2. +2
    -2
      src/Services/Ordering/Ordering.API/Application/Queries/OrderQueries.cs
  3. +3
    -2
      src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs
  4. +3
    -2
      test/Services/UnitTest/Ordering/Application/OrdersWebApiTest.cs

+ 3
- 2
src/Services/Ordering/Ordering.API/Application/Queries/IOrderQueries.cs View File

@ -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();
}
}

+ 2
- 2
src/Services/Ordering/Ordering.API/Application/Queries/OrderQueries.cs View File

@ -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))
{


+ 3
- 2
src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs View File

@ -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);
}


+ 3
- 2
test/Services/UnitTest/Ordering/Application/OrdersWebApiTest.cs View File

@ -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…
Cancel
Save