Fix API signatures for collections
The methods that return collections should return Task<IEnumerable<dynamic>> not Task<dynamic>
This commit is contained in:
		
							parent
							
								
									2785dd7932
								
							
						
					
					
						commit
						995cc890ff
					
				| @ -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,13 +44,13 @@ | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public async Task<dynamic> GetOrdersAsync() |         public Task<IEnumerable<dynamic>> GetOrdersAsync() | ||||||
|         { |         { | ||||||
|             using (var connection = new SqlConnection(_connectionString)) |             using (var connection = new SqlConnection(_connectionString)) | ||||||
|             { |             { | ||||||
|                 connection.Open(); |                 connection.Open(); | ||||||
| 
 | 
 | ||||||
|                 return await connection.QueryAsync<dynamic>(@"SELECT o.[Id] as ordernumber,o.[OrderDate] as [date],os.[Name] as [status],SUM(oi.units*oi.unitprice) as total
 |                 return connection.QueryAsync<dynamic>(@"SELECT o.[Id] as ordernumber,o.[OrderDate] as [date],os.[Name] as [status],SUM(oi.units*oi.unitprice) as total
 | ||||||
|                      FROM [ordering].[Orders] o |                      FROM [ordering].[Orders] o | ||||||
|                      LEFT JOIN[ordering].[orderitems] oi ON  o.Id = oi.orderid  |                      LEFT JOIN[ordering].[orderitems] oi ON  o.Id = oi.orderid  | ||||||
|                      LEFT JOIN[ordering].[orderstatus] os on o.OrderStatusId = os.Id |                      LEFT JOIN[ordering].[orderstatus] os on o.OrderStatusId = os.Id | ||||||
| @ -58,13 +58,13 @@ | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public async Task<dynamic> GetCardTypesAsync() |         public Task<IEnumerable<dynamic>> GetCardTypesAsync() | ||||||
|         { |         { | ||||||
|             using (var connection = new SqlConnection(_connectionString)) |             using (var connection = new SqlConnection(_connectionString)) | ||||||
|             { |             { | ||||||
|                 connection.Open(); |                 connection.Open(); | ||||||
| 
 | 
 | ||||||
|                 return await connection.QueryAsync<dynamic>("SELECT * FROM ordering.cardtypes"); |                 return connection.QueryAsync<dynamic>("SELECT * FROM ordering.cardtypes"); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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