using System;
using CurrencyExchangeLib;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CurrencyExchangeTestLib
{
    [TestClass]
    public class CurrencyExchangeTest
    {
        const double DELTA = 0.000001;
        CurrencyExchange currencyExchange;

        class VendorRateWebServiceMock : IVendorRateWebService
        {
            public double GetExchange(string vendor, string currency)
            {
                return 100;
            }
        }

        [TestInitialize]
        public void Init()
        {
            currencyExchange = new CurrencyExchange(new VendorRateWebServiceMock());
        }

        [TestMethod]
        public void Canary()
        {
            Assert.IsTrue(true);
        }

        [TestMethod]
        public void MarkDown()
        {
            Assert.AreEqual(98.0, currencyExchange.MarkDown(100), DELTA);
        }

        [TestMethod]
        public void GetRateNoVendors()
        {
            var result = new Tuple<String, double>("", 0.0);
            Assert.AreEqual(result, currencyExchange.GetRate("GBP"));
        }

        [TestMethod]
        public void GetRateWithOneVendor()
        {
            var result = new Tuple<string, double>("vendor1", 98.0);
            currencyExchange.SetVendor("vendor1");
            Assert.AreEqual(result, currencyExchange.GetRate("GBP"));
        }
    }
}
