private void Convert(Conversion conversion)
        {
            if (cmbLeftCurrency.SelectedItem == null || cmbRightCurrency.SelectedItem == null)
            {
                return;
            }

            string leftCurrency  = ((CurrencyData)cmbLeftCurrency.SelectedItem).Symbol;
            string rightCurrency = ((CurrencyData)cmbRightCurrency.SelectedItem).Symbol;

            double input;

            if (conversion == Conversion.LeftToRight)
            {
                if (double.TryParse(txtLeftValue.Text, out input))
                {
                    txtRightValue.Text = calculator.Convert(input, leftCurrency, rightCurrency).ToString("F2");
                }
            }
            else
            {
                if (double.TryParse(txtRightValue.Text, out input))
                {
                    txtLeftValue.Text = calculator.Convert(input, rightCurrency, leftCurrency).ToString("F2");
                }
            }
        }
示例#2
0
        public void Convert_MoneyExchangeRequestIsNull_ShouldThrowException()
        {
            //Arrange
            var moneyExchangeRequest = null as MoneyExchangeRequest;

            //Act && Assert
            var message = Should.Throw <DomainException>(() =>
                                                         _currencyCalculator.Convert(moneyExchangeRequest)).Message;

            message.ShouldBe("MoneyExchangeRequest cannot be null");
        }