コード例 #1
0
        public void CalculatorService_ComputeTotalTransactionValueByCurrency_Throws_Exception_When_Missing_Rate()
        {
            // Arrange
            IEnumerable <BusinessTransaction> transactions = GetTestData.GetTestTransactions();
            IEnumerable <ConversionRate>      rates        = GetTestData.GetTestRates();
            CalculatorService    calculator = new CalculatorService();
            IEnumerable <Amount> amounts    = transactions.Select(t => new Amount {
                Value = t.Amount, Currency = t.Currency
            });

            // Act
            decimal total = calculator.ComputeTotalTransactionValueByCurrency(amounts, rates, CurrencyCode.TRY);

            // Assert - Expects exception
        }
コード例 #2
0
        public void CalculatorService_ComputeTotalTransactionValueByCurrency_Returns_Correct_Total_With_Existing_Rates()
        {
            // Arrange
            IEnumerable <BusinessTransaction> transactions = GetTestData.GetTestTransactions();
            IEnumerable <ConversionRate>      rates        = GetTestData.GetTestRates();
            CalculatorService    calculator = new CalculatorService();
            IEnumerable <Amount> amounts    = transactions.Select(t => new Amount {
                Value = t.Amount, Currency = t.Currency
            });

            // Act
            decimal total = calculator.ComputeTotalTransactionValueByCurrency(amounts, rates, CurrencyCode.EUR);

            //Assert
            Assert.AreEqual(69.13172M, total);
        }