public void Initialize() { brandQuantityDto = new List <BrandQuantityDto>(); inventoryAggregationDto = new InventoryAggregationDto(); aggregationManagerServiceMock = new Mock <IAggregationManagerService>(); aggregationManagerServiceMock.Setup(x => x.GetAggregationResultsAgainstInventory(inventoryAggregationDto)) .Returns(brandQuantityDto); inventoriesController = new InventoriesController(aggregationManagerServiceMock.Object); }
public void Initialize() { brandQuantityDto = new List <BrandQuantityDto>(); inventoryAggregationDto = new InventoryAggregationDto(); inventoryServiceMock = new Mock <IInventoryService>(); inventoryServiceMock.Setup(x => x.GetBrandsQuantity()) .Returns(brandQuantityDto); aggregationManagerService = new AggregationManagerService(inventoryServiceMock.Object); }
/// <summary> /// Returns sum of items for each brand /// </summary> /// <param name="aggregationInfo">Aggregation operation info</param> /// <returns>Returns list of <seealso cref="BrandQuantityDto"></seealso> type</returns> public List <BrandQuantityDto> GetAggregationResultsAgainstInventory(InventoryAggregationDto aggregationInfo) { if (!(string.Equals(aggregationInfo.AggregateType, "sum", StringComparison.InvariantCultureIgnoreCase) && string.Equals(aggregationInfo.ColumnName, "quantity", StringComparison.InvariantCultureIgnoreCase))) { throw new UnsupportedAggregationActionException(aggregationInfo.AggregateType, aggregationInfo.ColumnName); } var aggregationResult = _inventoryService.GetBrandsQuantity().ToList(); return(aggregationResult); }
public ActionResult <List <BrandQuantityDto> > Get([FromQuery] InventoryAggregationDto aggregationInfo) { var results = _aggregationManagerService.GetAggregationResultsAgainstInventory(aggregationInfo); return(Ok(results)); }