public void ContractAggregate_DisableTransactionFee_TransactionFeeIsDisabled(CalculationType calculationType, FeeType feeType) { ContractAggregate aggregate = ContractAggregate.Create(TestData.ContractId); aggregate.Create(TestData.EstateId, TestData.OperatorId, TestData.ContractDescription); aggregate.AddVariableValueProduct(TestData.ProductId, TestData.ProductName, TestData.ProductDisplayText); List <Product> products = aggregate.GetProducts(); Product product = products.Single(); aggregate.AddTransactionFee(product, TestData.TransactionFeeId, TestData.TransactionFeeDescription, calculationType, feeType, TestData.TransactionFeeValue); List <Product> productsAfterFeeAdded = aggregate.GetProducts(); Product productWithFees = productsAfterFeeAdded.Single(); productWithFees.TransactionFees.ShouldHaveSingleItem(); TransactionFee fee = productWithFees.TransactionFees.Single(); fee.IsEnabled.ShouldBeTrue(); aggregate.DisableTransactionFee(TestData.ProductId, TestData.TransactionFeeId); productsAfterFeeAdded = aggregate.GetProducts(); productWithFees = productsAfterFeeAdded.Single(); productWithFees.TransactionFees.ShouldHaveSingleItem(); fee = productWithFees.TransactionFees.Single(); fee.IsEnabled.ShouldBeFalse(); }
public void ContractAggregate_DisableTransactionFee_ProductNotFound_ErrorThrown() { ContractAggregate aggregate = ContractAggregate.Create(TestData.ContractId); aggregate.Create(TestData.EstateId, TestData.OperatorId, TestData.ContractDescription); Should.Throw <InvalidOperationException>(() => { aggregate.DisableTransactionFee(TestData.ProductId, TestData.TransactionFeeId); }); }
/// <summary> /// Disables the transaction fee for product. /// </summary> /// <param name="transactionFeeId">The transaction fee identifier.</param> /// <param name="contractId">The contract identifier.</param> /// <param name="productId">The product identifier.</param> /// <param name="cancellationToken">The cancellation token.</param> public async Task DisableTransactionFeeForProduct(Guid transactionFeeId, Guid contractId, Guid productId, CancellationToken cancellationToken) { // Get the contract aggregate ContractAggregate contractAggregate = await this.ContractAggregateRepository.GetLatestVersion(contractId, cancellationToken); contractAggregate.DisableTransactionFee(productId, transactionFeeId); await this.ContractAggregateRepository.SaveChanges(contractAggregate, cancellationToken); }