private bool ValuesEqual(TradePrice price, ProfitAnalysis optimalProfit) { return (price.Date.Equals(optimalProfit.PurchaseDate) && price.Date.Equals(optimalProfit.SaleDate) && price.OpeningPrice.Equals(optimalProfit.PurchasePrice) && price.ClosingPrice.Equals(optimalProfit.SalePrice)); }
public void GetOptimalProfitPeriod_ShouldReturnCorrectRange() { var prices = CreatePriceSet(); var optimalProfit = GetOptimalProfit(prices.ToArray()); var correctProfit = new ProfitAnalysis( purchaseDate: prices.ElementAt(2).Date, saleDate: prices.ElementAt(5).Date, purchasePrice: prices.ElementAt(2).OpeningPrice, salePrice: prices.ElementAt(5).ClosingPrice ); Assert.AreEqual(correctProfit, optimalProfit); }
public void GetOptimalProfitPeriod_ShouldReturnFirstOpeningSecondClosingDetails() { var prices = new TradePrice[] { TradePrice.Create(new DateTime(2010, 01, 01), 30, 33), TradePrice.Create(new DateTime(2010, 01, 02), 33, 36) }; var optimalProfit = GetOptimalProfit(prices); var correctProfit = new ProfitAnalysis( purchaseDate: prices[0].Date, saleDate: prices[1].Date, purchasePrice: prices[0].OpeningPrice, salePrice: prices[1].ClosingPrice ); Assert.AreEqual(correctProfit, optimalProfit); }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex != -1) { textBox1.Text = ""; ManagerBD mbd = new ManagerBD(); mbd.Connection(); DataTable dt = mbd.selectionquery("select count(*) from zakaz where month_zakaz = " + Convert.ToString(comboBox1.SelectedItem)); if (Convert.ToInt32(dt.Rows[0][0]) != 0) { ProfitAnalysis pa = new ProfitAnalysis(); textBox1.Text = pa.Analis(Convert.ToInt32(comboBox1.SelectedItem)); } else { textBox1.Text = "В этом месяце не было заказов"; } } else { MessageBox.Show("Выберите месяц", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }