public void CurrencyPair_PassingNameInLowerCase_ShouldChangeNameToUpperCase() { string name = "usd/rub"; CurrencyPair currencyPair = new CurrencyPair(name); Assert.That(currencyPair.Name, Is.EqualTo(name.ToUpper())); }
public void UpdateValuesBy_PassingOtherCurrencyPairArgument_ShouldThrowArgumentException() { const decimal bid = 87; const decimal ask = 89; CurrencyPair mainCurrencyPair = new CurrencyPair("USD/RUB"); CurrencyPair sourceCurrencyPair = new CurrencyPair("EUR/RUB", bid, ask); Assert.Throws(typeof(ArgumentException), () => mainCurrencyPair.UpdateValuesBy(sourceCurrencyPair)); }
public void UpdateValuesBy_NullArgument_ShouldNotUpdateItsFields() { const decimal bid = 77; const decimal ask = 79; CurrencyPair currencyPair = new CurrencyPair("USD/RUB", bid, ask); currencyPair.UpdateValuesBy(null); Assert.That(currencyPair.Bid, Is.EqualTo(bid)); Assert.That(currencyPair.Ask, Is.EqualTo(ask)); }
public void UpdateValuesBy_PassingSameCurrencyPairArgument_ShouldUpdateItsFields() { const decimal bid = 77; const decimal ask = 79; CurrencyPair mainCurrencyPair = new CurrencyPair("USD/RUB"); CurrencyPair sourceCurrencyPair = new CurrencyPair("USD/RUB", bid, ask); mainCurrencyPair.UpdateValuesBy(sourceCurrencyPair); Assert.That(mainCurrencyPair.Bid, Is.EqualTo(bid)); Assert.That(mainCurrencyPair.Ask, Is.EqualTo(ask)); }
// --- --- --- --- --- #region :: ~ Methods ~ :: public void UpdateValuesBy(CurrencyPair currencyPair) { if (currencyPair == null) return; if (currencyPair.Name != this.Name) throw new ArgumentException("CurrencyPair names does not correspond to each other"); this.Bid = currencyPair.Bid; this.Ask = currencyPair.Ask; }
public void UpdateValuesBy_NullArgument_DoesNotThrowAnException() { CurrencyPair currencyPair = new CurrencyPair("USD/RUB"); Assert.DoesNotThrow(() => currencyPair.UpdateValuesBy(null)); }