コード例 #1
0
        public void ContractAggregate_AddVariableValueProduct_DuplicateProduct_ErrorThrown()
        {
            ContractAggregate aggregate = ContractAggregate.Create(TestData.ContractId);

            aggregate.Create(TestData.EstateId, TestData.OperatorId, TestData.ContractDescription);

            aggregate.AddVariableValueProduct(TestData.ProductId, TestData.ProductName, TestData.ProductDisplayText);

            Should.Throw <InvalidOperationException>(() =>
            {
                aggregate.AddVariableValueProduct(TestData.ProductId, TestData.ProductName, TestData.ProductDisplayText);
            });
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        /// <summary>
        /// Adds the product to contract.
        /// </summary>
        /// <param name="productId">The product identifier.</param>
        /// <param name="contractId">The contract identifier.</param>
        /// <param name="productName">Name of the product.</param>
        /// <param name="displayText">The display text.</param>
        /// <param name="value">The value.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <exception cref="System.InvalidOperationException">Contract Id [{contractId}] must be created to add products</exception>
        public async Task AddProductToContract(Guid productId,
                                               Guid contractId,
                                               String productName,
                                               String displayText,
                                               Decimal?value,
                                               CancellationToken cancellationToken)
        {
            // Get the contract aggregate
            ContractAggregate contractAggregate = await this.ContractAggregateRepository.GetLatestVersion(contractId, cancellationToken);

            // Check for a duplicate
            if (contractAggregate.IsCreated == false)
            {
                throw new InvalidOperationException($"Contract Id [{contractId}] must be created to add products");
            }

            if (value.HasValue)
            {
                contractAggregate.AddFixedValueProduct(productId, productName, displayText, value.Value);
            }
            else
            {
                contractAggregate.AddVariableValueProduct(productId, productName, displayText);
            }

            await this.ContractAggregateRepository.SaveChanges(contractAggregate, cancellationToken);
        }
コード例 #4
0
        public void ContractAggregate_AddVariableValueProduct_InvalidProductDisplayText_ErrorThrown(String displayText)
        {
            ContractAggregate aggregate = ContractAggregate.Create(TestData.ContractId);

            aggregate.Create(TestData.EstateId, TestData.OperatorId, TestData.ContractDescription);

            Should.Throw <ArgumentNullException>(() =>
            {
                aggregate.AddVariableValueProduct(TestData.ProductId, TestData.ProductName, displayText);
            });
        }
コード例 #5
0
        public void ContractAggregate_AddTransactionFee_VariableValueProduct_InvalidFeeType_ErrorThrown(CalculationType calculationType)
        {
            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();

            Should.Throw <ArgumentOutOfRangeException>(() =>
            {
                aggregate.AddTransactionFee(product, TestData.TransactionFeeId, TestData.TransactionFeeDescription, calculationType, (FeeType)99, TestData.TransactionFeeValue);
            });
        }
コード例 #6
0
        public void ContractAggregate_AddVariableValueProduct_ProductAdded()
        {
            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();

            products.Count.ShouldBe(1);
            products.First().ProductId.ShouldNotBe(Guid.Empty);
            products.First().Name.ShouldBe(TestData.ProductName);
            products.First().DisplayText.ShouldBe(TestData.ProductDisplayText);
            products.First().Value.ShouldBeNull();
        }