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();
        }
Esempio n. 2
0
        public void Forbids_improperly_formatted_value(string value)
        {
            Action createCurrencyCode = () => CurrencyCode.Of(value);

            createCurrencyCode.Should().ThrowExactly <DomainException>()
            .Which.Error.Should().Be(CurrencyCodeInvalidFormat);
        }
        public void Requires_rate()
        {
            Action createQuoteCurrency = () =>
                                         QuoteCurrency.Of(CurrencyCode.Of(USD), null);

            createQuoteCurrency.Should().ThrowExactly <ArgumentException>();
        }
Esempio n. 4
0
        public void Requires_non_blank_value(string value)
        {
            Action createCurrencyCode = () => CurrencyCode.Of(value);

            createCurrencyCode.Should().ThrowExactly <DomainException>()
            .Which.Error.Should().Be(MissingCurrencyCode);
        }
Esempio n. 5
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));
        }
Esempio n. 6
0
 private bool Equals(CurrencyCode other) =>
 string.Equals(_value, other._value, StringComparison.OrdinalIgnoreCase);
Esempio n. 7
0
        public void Uppercase_the_value()
        {
            string currencyCodeValue = CurrencyCode.Of("bTc");

            currencyCodeValue.Should().Be(BTC);
        }
Esempio n. 8
0
        public void Is_successfully_created_from_a_non_blank_value()
        {
            Action createCurrencyCode = () => CurrencyCode.Of(BTC);

            createCurrencyCode.Should().NotThrow();
        }
Esempio n. 9
0
 private QuoteCurrency(CurrencyCode code, CurrencyExchangeRate exchangeRate)
 {
     Code         = code;
     ExchangeRate = exchangeRate;
 }