예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        public ActionResult Convert(decimal exchangeRate)
        {
            var service = new PriceService(catalogDb);

            return(View(service.CalculateForeignPrices(exchangeRate)));
        }