public void Is_successfully_created_when_both_code_and_exchange_rate_are_provided()
        {
            Action createQuoteCurrency = () =>
                                         QuoteCurrency.Of(CurrencyCode.Of(USD), CurrencyExchangeRate.Of(BTC_to_USD));

            createQuoteCurrency.Should().NotThrow();
        }
        public void Requires_code()
        {
            Action createQuoteCurrency = () =>
                                         QuoteCurrency.Of(null, CurrencyExchangeRate.Of(BTC_to_USD));

            createQuoteCurrency.Should().ThrowExactly <ArgumentException>();
        }
Exemple #3
0
        public static QuoteCurrency Of(CurrencyCode code, CurrencyExchangeRate exchangeRate)
        {
            if (code is null)
            {
                throw new ArgumentException(
                          $"{nameof(QuoteCurrency)} {nameof(code)} is required.", nameof(code));
            }
            if (exchangeRate is null)
            {
                throw new ArgumentException(
                          $"{nameof(QuoteCurrency)} {nameof(exchangeRate)} is required.", nameof(exchangeRate));
            }

            return(new QuoteCurrency(code, exchangeRate));
        }
Exemple #4
0
        public void Is_successfully_created_from_a_non_zero_positive_value()
        {
            Action createCurrencyExchangeRate = () => CurrencyExchangeRate.Of(0.5M);

            createCurrencyExchangeRate.Should().NotThrow();
        }
Exemple #5
0
        public void Requires_value_higher_than_zero(decimal value)
        {
            Action createCurrencyExchangeRate = () => CurrencyExchangeRate.Of(value);

            createCurrencyExchangeRate.Should().ThrowExactly <ArgumentException>();
        }
 private bool Equals(CurrencyExchangeRate other) => _value == other._value;
Exemple #7
0
 private QuoteCurrency(CurrencyCode code, CurrencyExchangeRate exchangeRate)
 {
     Code         = code;
     ExchangeRate = exchangeRate;
 }