Пример #1
0
 public BaseFeeCalculator(
     ITransactionFee defaultFee,
     IReadOnlyDictionary <string, ITransactionFee> customFeesByMerchantName)
 {
     _defaultFee = defaultFee;
     _customFees = customFeesByMerchantName;
 }
 /// <inheritdoc />
 public void Format(ITransactionFee fee, StringBuilder builder)
 {
     if (builder == null)
     {
         throw new ArgumentNullException(nameof(builder));
     }
     builder.Append(InternalFormat(fee));
 }
        private string InternalFormat(ITransactionFee fee)
        {
            if (fee == null)
            {
                throw new ArgumentNullException(nameof(fee));
            }

            // TODO: optimize performance if needed
            return($"{fee.Transaction.Date:yyyy-MM-dd} {fee.Transaction.Merchant.Name.PadRight(10)} {fee.Value:C}");
        }
Пример #4
0
            /// <inheritdoc />
            public void Write(ITransactionFee fee, ITransactionFeeOutputFormatter formatter)
            {
                var line = formatter.Format(fee);

                if (_assertFile.Peek() >= 0)
                {
                    var assertLine = _assertFile.ReadLine();
                    Assert.AreEqual(line, assertLine, "Transaction fee formatted lines are different.");
                }
                else
                {
                    Assert.Fail("Too many transactions written!");
                }
            }
Пример #5
0
 /// <inheritdoc />
 public void Write(ITransactionFee fee, ITransactionFeeOutputFormatter formatter)
 {
     Assert.AreEqual(_transactionFeeResults[_indexer++], formatter.Format(fee));
 }
 /// <inheritdoc />
 public string Format(ITransactionFee fee) => InternalFormat(fee);
Пример #7
0
 /// <inheritdoc />
 public void Write(ITransactionFee fee, ITransactionFeeOutputFormatter formatter)
 {
     Console.WriteLine(formatter.Format(fee));
 }