public void ToString_WithInvalidPriceInfo_ReturnsFormattedString() { string expected = $"PriceInfo: Success = False, Error = '', ItemId = 0, ItemName = '', " + $"HighSellPrices(0) = [], LowSellPrices(0) = [], HighBuyPrices(0) = [], LowBuyPrices(0) = [], " + $"OneDayAverage = 0, SevenDayAverage = 0"; _priceInfo = JsonConvert.DeserializeObject <PriceInfo>(PriceInfoTestData.INVALID_PRICE_INFO_JSON); Assert.AreEqual(expected, _priceInfo.ToString()); }
protected decimal CalculateOrderByPizza(string composition, double ingredientWeight, string pizzaDecorators) { Type myType = Type.GetType(priceInfo.ToString(), false, true); decimal totalPrice = 0; foreach (MemberInfo property in myType.GetProperties()) { if (property.Name == composition) { decimal price = (decimal)(priceInfo.GetType().GetProperty(property.Name).GetValue(priceInfo, null)); totalPrice += (price * (decimal)(Convert.ToDouble(ingredientWeight) / 1000)) * (decimal)priceCategory; } else if (property.Name == pizzaDecorators) { decimal price = (decimal)(priceInfo.GetType().GetProperty(property.Name).GetValue(priceInfo, null)); totalPrice += (price * (decimal)priceCategory); } } return(totalPrice); }
public void ToString_WithSuccesPriceInfo_ReturnsFormattedString() { string expected = $"PriceInfo: Success = True, Error = '', ItemId = {ItemTestData.ITEM_ID}, ItemName = '{ItemTestData.ITEM_NAME}', " + $"HighSellPrices({PriceInfoTestData.HIGH_SELL_PRICES.Count}) = [{string.Join(", ", PriceInfoTestData.HIGH_SELL_PRICES)}], " + $"LowSellPrices({PriceInfoTestData.LOW_SELL_PRICES.Count}) = [{string.Join(", ", PriceInfoTestData.LOW_SELL_PRICES)}], " + $"HighBuyPrices({PriceInfoTestData.HIGH_BUY_PRICES.Count}) = [{string.Join(", ", PriceInfoTestData.HIGH_BUY_PRICES)}], " + $"LowBuyPrices({PriceInfoTestData.LOW_BUY_PRICES.Count}) = [{string.Join(", ", PriceInfoTestData.LOW_BUY_PRICES)}], " + $"OneDayAverage = {PriceInfoTestData.ONE_DAY_AVERAGE}, SevenDayAverage = {PriceInfoTestData.SEVEN_DAY_AVERAGE}"; _priceInfo = JsonConvert.DeserializeObject <PriceInfo>(PriceInfoTestData.SUCCESS_PRICE_INFO_JSON); Assert.AreEqual(expected, _priceInfo.ToString()); }
public void SetChartSeries(int minValue, int maxValue) { for (int nIdx = 0; nIdx < priceInfoList.Count; nIdx++) { PriceInfo entity = priceInfoList[nIdx]; // adding date and high mainView.PriceSeries.Points.AddXY(entity.Date, entity.Highest); mainView.PriceSeries.Points[nIdx].YValues[1] = entity.Lowest; mainView.PriceSeries.Points[nIdx].YValues[2] = entity.Start; mainView.PriceSeries.Points[nIdx].YValues[3] = entity.End; mainView.PriceSeries.Points[nIdx].ToolTip = entity.ToString(); mainView.VolumeSeries.Points.AddXY(entity.Date, entity.Volume); mainView.VolumeSeries.Points[nIdx].Color = Color.FromArgb(128, 0, 40, 250); mainView.VolumeSeries.Points[nIdx].ToolTip = "일자 : " + entity.Date + "\n" + "거래량 : " + String.Format("{0:#,###}", entity.Volume); } ChartArea priceChartArea = mainView.MainChart.ChartAreas["PriceChartArea"]; if (priceInfoList.Count > 0) { priceChartArea.AxisX.ScaleView.ZoomReset(); priceChartArea.AxisY.Maximum = maxValue; priceChartArea.AxisY.Minimum = minValue; if (!priceChartArea.AxisX.ScaleView.IsZoomed) { int startPosition = (int)priceChartArea.AxisX.ScaleView.ViewMinimum; int endPosition = (int)priceChartArea.AxisX.ScaleView.ViewMaximum; UpdateChartAxis(startPosition, endPosition); SetViewPeriod(startPosition, endPosition); } HighlightArea(HighlightOption.MFI); } }