public void CalculateResult2()
 {
     var calculator = new RatesCalculator(Mock.Of<IRateRepository>(), Mock.Of<IRatesLoadService>());
     var rates = RatesDataSet2();
     var result = calculator.CalculateResult(Currency.USD, new[] { Currency.RUB }, 50m, rates);
     Assert.AreEqual(Currency.RUB, result.Currency);
     Assert.AreEqual(new DateTime(2012, 1, 5), result.StartDate);
     Assert.AreEqual(new DateTime(2012, 1, 7), result.EndDate);
     Assert.IsTrue(55.142857142857146m - result.MaxAmount < 0.000000001m);
 }
        public void CalculateResult_NoDeal()
        {
            var calculator = new RatesCalculator(Mock.Of<IRateRepository>(), Mock.Of<IRatesLoadService>());
            var rates = new List<Rate>
            {
                new Rate { BaseCurrency = Currency.USD, Date = new DateTime(2012, 12, 1), Rates = new Dictionary<Currency, decimal> {{Currency.RUB, 10m}}},
                new Rate { BaseCurrency = Currency.USD, Date = new DateTime(2012, 12, 2), Rates = new Dictionary<Currency, decimal> {{Currency.RUB, 20m}}}
            };
            var result = calculator.CalculateResult(Currency.USD, new [] {Currency.RUB}, 100, rates);

            //if traider can only lose money, CalculateResult return MaxAmount = initial amount and Currency = initial currency
            Assert.AreEqual(Currency.USD, result.Currency);
            Assert.AreEqual(100m, result.MaxAmount);
        }
 public void CalculateResult1()
 {
     var calculator = new RatesCalculator(Mock.Of<IRateRepository>(), Mock.Of<IRatesLoadService>());
     var rates = RatesDateSet1();
     var result = calculator.CalculateResult(Currency.USD, new [] {Currency.RUB}, 100m, rates);
     Assert.AreEqual(Currency.RUB, result.Currency);
     Assert.AreEqual(new DateTime(2012, 12, 16), result.StartDate);
     Assert.AreEqual(new DateTime(2012, 12, 22), result.EndDate);
     Assert.IsTrue(127.26m - result.MaxAmount < 0.005m);
 }