コード例 #1
0
        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();
        }
コード例 #2
0
        public void Forbids_improperly_formatted_value(string value)
        {
            Action createCurrencyCode = () => CurrencyCode.Of(value);

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

            createQuoteCurrency.Should().ThrowExactly <ArgumentException>();
        }
コード例 #4
0
        public void Requires_non_blank_value(string value)
        {
            Action createCurrencyCode = () => CurrencyCode.Of(value);

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

            currencyCodeValue.Should().Be(BTC);
        }
コード例 #8
0
        public void Is_successfully_created_from_a_non_blank_value()
        {
            Action createCurrencyCode = () => CurrencyCode.Of(BTC);

            createCurrencyCode.Should().NotThrow();
        }
コード例 #9
0
 private QuoteCurrency(CurrencyCode code, CurrencyExchangeRate exchangeRate)
 {
     Code         = code;
     ExchangeRate = exchangeRate;
 }