public void SimpleConversion() { // TODO Test currently hits a real database, replace with something in-memory using (var db = new CycleSalesContext()) { // Arange db.Bikes.Add(new Bike { Bike_Id = 1, Retail = 100M }); db.Bikes.Add(new Bike { Bike_Id = 2, Retail = 99.95M }); db.SaveChanges(); // Act var convertor = new PriceService(db); var results = convertor.CalculateForeignPrices(exchangeRate: 2).ToArray(); // Assert Assert.AreEqual(2, results.Length); Assert.AreEqual(100M, results[0].USPrice); Assert.AreEqual(199.95M, results[0].ForeignPrice); Assert.AreEqual(99.95M, results[1].USPrice); Assert.AreEqual(199.90M, results[1].ForeignPrice); } }
public void SimpleConversion() { var options = new DbContextOptions() .UseInMemoryStore(); using (var db = new CycleSalesContext(options)) { // Arange db.Bikes.Add(new Bike { Bike_Id = 1, Retail = 100M }); db.Bikes.Add(new Bike { Bike_Id = 2, Retail = 99.95M }); db.SaveChanges(); // Act var convertor = new PriceService(db); var results = convertor.CalculateForeignPrices(exchangeRate: 2).ToArray(); // Assert Assert.AreEqual(2, results.Length); Assert.AreEqual(100M, results[0].USPrice); Assert.AreEqual(199.95M, results[0].ForeignPrice); Assert.AreEqual(99.95M, results[1].USPrice); Assert.AreEqual(199.90M, results[1].ForeignPrice); } }
private void buttonGo_Click(object sender, EventArgs e) { var exchangeRate = decimal.Parse(this.textExchangeRate.Text); using (var db = new CycleSalesContext()) { var convertor = new PriceService(db); this.dataGridView1.DataSource = convertor.CalculateForeignPrices(exchangeRate); } }
public ActionResult Convert(decimal exchangeRate) { var service = new PriceService(catalogDb); return(View(service.CalculateForeignPrices(exchangeRate))); }