public void AServiceChargeIsATypeOfTransaction()
 {
     Tax defaultTax = new Tax("No Tax", 0);
     ClubService clubService = new ClubService("Member Fee", 79, defaultTax);
     Transaction serviceCharge = new ServiceCharge(clubService, "June Full Membership Fee", 1, 0);
     Assert.AreEqual((decimal)79, serviceCharge.NetAmount);
 }
 public void ASaleIsATypeOfTransaction()
 {
     Tax defaultTax = new Tax("5% Tax", 5);
     Product simpleProduct = new Product("A Cap", 10, defaultTax);
     Transaction sale = new Sale(simpleProduct, "Selling a cap", 1, 0);
     Assert.AreEqual((decimal)10.5, sale.NetAmount);
 }
 public void InstantiatingASimpleProductThatHasADescriptionCostAndAplicapleTax()
 {
     Tax defaultTax = new Tax("5% Tax", 5);
     ClubService simpleService = new ClubService("Optimist Rent", 10, defaultTax);
     Assert.AreEqual("Optimist Rent", simpleService.Description);
     Assert.AreEqual(10,simpleService.Cost);
     Assert.AreEqual(defaultTax, simpleService.Tax);
 }
 public ClubService(string description, double cost, Tax tax)
 {
     if (cost < 0) throw new System.ArgumentException("Service cost can't be negative", "taxName");
     if ((description ?? "").Trim() == "") throw new System.ArgumentException("Service name can't be empty or null", "taxName");
     this.description = description;
     this.cost = cost;
     this.tax = tax;
 }
 public void InstantiatingASimpleProductThatHasADiscriptionCostAndAplicapleTax()
 {
     Tax defaultTax = new Tax("5% Tax", 5);
     Product simpleProduct = new Product("A Cap", 10, defaultTax);
     Assert.AreEqual("A Cap",simpleProduct.Description);
     Assert.AreEqual(10,simpleProduct.Cost);
     Assert.AreEqual(defaultTax, simpleProduct.Tax);
 }
 public ServiceCharge(ClubService service, string concept, int units, double unitCost, Tax tax, double discount)
     : base(concept, units, unitCost, tax, discount)
 {
     this.service = service;
     this.concept = concept;
     this.units = units;
     this.unitCost = unitCost;
     this.tax = tax;
     this.discount = discount;
 }
 public Transaction(string description, int units, double unitCost, Tax tax, double discount)
 {
     if (unitCost < 0) throw new System.ArgumentOutOfRangeException("uniCost", "Transactions units cost can't be negative");
     if (units == 0) throw new System.ArgumentOutOfRangeException("units", "A transaction can't have zero units");
     this.description = description;
     this.units = units;
     this.unitCost = unitCost;
     this.tax = tax;
     this.discount = discount;
 }
예제 #8
0
 public Sale(Product product, string concept, int units, double unitCost, Tax tax, double discount)
     : base(concept, units, unitCost, tax, discount)
 {
     this.product = product;
     this.concept = concept;
     this.units = units;
     this.unitCost = unitCost;
     this.tax = tax;
     this.discount = discount;
 }
 public void ServiceCostCantBeNegative()
 {
     Tax defaultTax = new Tax("5% Tax", 5);
     try
     {
         ClubService simpleService = new ClubService(null, -1, defaultTax);
     }
     catch (ArgumentException exception)
     {
         Assert.AreEqual("Service cost can't be negative", exception.GetMessageWithoutParamName());
         throw exception;
     }
 }
 public void ProductDescriptionCanNotBeJustSpaces()
 {
     Tax defaultTax = new Tax("5% Tax", 5);
     try
     {
         Product simpleService = new Product("   ", 10, defaultTax);
     }
     catch (ArgumentException exception)
     {
         Assert.AreEqual("Product name can't be empty or null", exception.GetMessageWithoutParamName());
         throw exception;
     }
 }
 public void ServiceDescriptionCanNotBeNull()
 {
     Tax defaultTax = new Tax("5% Tax", 5);
     try
     {
         ClubService simpleService = new ClubService(null, 10, defaultTax);
     }
     catch (ArgumentException exception)
     {
         Assert.AreEqual("Service name can't be empty or null", exception.GetMessageWithoutParamName());
         throw exception;
     }
 }
        public void TaxNameCanNotBeNull()
        {
            try
            {
                Tax tax = new Tax(null, 5);

            }
            catch (ArgumentException exception)
            {
                Assert.AreEqual("Tax name can't be empty or null", exception.GetMessageWithoutParamName());
                throw exception;
            }
        }
 private List<Transaction> CreateAmendingTransactions(Invoice invoiceToAmend)
 {
     List<Transaction> amendingInvoiceDetail = new List<Transaction>();
     Tax voidTax = new Tax("", 0);
     Transaction originalInvoiceReference = new Transaction("Amending invoice " + invoiceToAmend.InvoiceID + "as detailed", 1, 0, voidTax, 0);
     amendingInvoiceDetail.Add(originalInvoiceReference);
     foreach (Transaction transaction in invoiceToAmend.InvoiceDetail)
     {
         Transaction amendedTransaction = new Transaction(
             "Amending " + transaction.Description, -transaction.Units, transaction.UnitCost, transaction.Tax, transaction.Discount);
         amendingInvoiceDetail.Add(amendedTransaction);
     }
     return amendingInvoiceDetail;
 }
 public void GivenThisSetOfTaxes(Table taxes)
 {
     invoiceContextData.taxesDictionary = new Dictionary<string, Tax>();
     foreach (var row in taxes.Rows)
     {
         string key = row["Tax Type"];
         Tax tax = new Tax((string)row["Tax Type"], double.Parse(row["Tax Value"]));
         invoiceContextData.taxesDictionary.Add(key, tax);
     }
 }
 public void TheTransactionsCostAndTaxesCanDiferFromDefaultProductCost()
 {
     Tax defaultTax = new Tax("5% Tax", 5);
     Product simpleProduct = new Product("A Cap", 10, defaultTax);
     Transaction sale = new Sale(simpleProduct, "Selling a cap", 1, 20, new Tax("No Tax", 0), 0);
     Assert.AreEqual((decimal)20, sale.NetAmount);
 }
 public void TheTransactionsCostAndTaxesCanDiferFromDefaultServiceCost()
 {
     Tax defaultTax = new Tax("No Tax", 0);
     ClubService clubService = new ClubService("Member Fee", 79, defaultTax);
     Transaction serviceCharge = new ServiceCharge(clubService, "June Full Membership Fee", 1, 80, new Tax("5% Tax", 5), 0);
     Assert.AreEqual((decimal)84, serviceCharge.NetAmount);
 }
        public void TaxPercentagesCanNotBeNegative()
        {
            try
            {
                Tax tax = new Tax("Negative TAX", -5);

            }
            catch (ArgumentOutOfRangeException exception)
            {
                Assert.AreEqual("Tax percentages can't be negative", exception.GetMessageWithoutParamName());
                throw exception;
            }
        }
 public void TaxPercentageCanBeZero()
 {
     Tax tax = new Tax("No Tax", 0);
     Assert.AreEqual(0, tax.TaxPercentage);
 }
 public void Special_VoidTax_CanBeZeroAndNullDescription()
 {
     Tax tax = new Tax(null, 0);
     Assert.AreEqual(0, tax.TaxPercentage);
 }
 public void CreatingATax()
 {
     Tax tax = new Tax("Canarian IGIC", 7);
     Assert.AreEqual(7, tax.TaxPercentage);
 }