Esempio n. 1
0
        public async Task Invoice_Must_Have_The_Expected_AdditionalData()
        {
            const string expectedKey   = "key";
            const string expectedValue = "value";

            _builder.AddProperty(expectedKey, expectedValue);

            var invoice = await _builder.BuildAsync();

            Assert.IsNotNull(invoice.Properties);
            Assert.IsTrue(invoice.Properties.ContainsKey(expectedKey));
            Assert.AreEqual(expectedValue, invoice.Properties[expectedKey]);
        }
        public static IInvoiceBuilder AddMellatCumulativeAccounts(this IInvoiceBuilder builder, IEnumerable <MellatCumulativeDynamicAccount> accounts)
        {
            if (accounts == null)
            {
                throw new ArgumentNullException(nameof(accounts));
            }
            if (!accounts.Any())
            {
                throw new ArgumentException("Accounts cannot be an empty collection.", nameof(accounts));
            }

            List <MellatCumulativeDynamicAccount> allAccounts = null;

            builder.ChangeProperties(data =>
            {
                if (data.ContainsKey(MellatHelper.CumulativeAccountsKey))
                {
                    allAccounts = (List <MellatCumulativeDynamicAccount>)data[MellatHelper.CumulativeAccountsKey];
                }
                else
                {
                    allAccounts = new List <MellatCumulativeDynamicAccount>();
                }

                allAccounts.AddRange(accounts);
            });

            builder.AddProperty(MellatHelper.CumulativeAccountsKey, allAccounts);

            return(builder);
        }
        /// <summary>
        /// Uses the given account to communicate with the gateway.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="accountName">Name of the account.</param>
        public static IInvoiceBuilder UseAccount(this IInvoiceBuilder builder, string accountName)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (accountName.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(accountName));
            }

            builder.AddProperty(GatewayAccountKeyName, accountName);

            return(builder);
        }