public static TransactionParamsDto CalculateTransactionParams(this TransactionEntity initialTransaction, decimal feeFactor) { var amount = initialTransaction.Amount; var fee = initialTransaction.Fee; var gasPrice = initialTransaction.GasPrice; var includeFee = initialTransaction.IncludeFee; if (includeFee) { amount += fee; } gasPrice = FeeFactorApplier.Apply(gasPrice, feeFactor); fee = gasPrice * Constants.EtcTransferGasAmount; if (includeFee) { amount -= fee; } return(new TransactionParamsDto { Amount = amount, Fee = fee, GasPrice = gasPrice }); }
public void Apply__ExpectedResultReturned(string gasPriceString, string feeFactorString, string expectedResultString) { var gasPrice = BigInteger.Parse(gasPriceString); var feeFactor = decimal.Parse(feeFactorString, CultureInfo.InvariantCulture); var expectedResult = BigInteger.Parse(expectedResultString); var actualResult = FeeFactorApplier.Apply(gasPrice, feeFactor); Assert.AreEqual(expectedResult, actualResult); }
public void Apply__FeeFactor_Lower_Then_One_Passed__ArgumentAxceptionThrown() { Assert.ThrowsException <ArgumentException>(() => { var gasPrice = new BigInteger(1); var feeFactor = 0.9m; // ReSharper disable once ReturnValueOfPureMethodIsNotUsed FeeFactorApplier.Apply(gasPrice, feeFactor); }); }