public void Add(Charge c)
 {
     if (c.Description=="")
     {
         throw(new UnassignedChargeException());
     }
     charges.Add(c);
 }
예제 #2
0
 public void AddCharge()
 {
     Charge charge=new Charge();
     charge.Description="Freight";
     charge.Amount=10.50;
     chargeSlip.Add(charge);
     Assert.AreEqual(chargeSlip.ChargeCount,1, "ChargeCount is wrong.");
 }
예제 #3
0
 public void RetrieveCharge()
 {
     Charge charge=new Charge();
     charge.Description="Freight";
     charge.Amount=10.50;
     chargeSlip.Add(charge);
     Charge c2=chargeSlip.Charges[0];
     Assert.AreEqual(c2.Description,charge.Description, "Descriptions do not match.");
 }
 public void ChargeConstructor()
 {
     charge=new Charge();
     Assert.AreEqual(charge.Description,"", "Description is not an empty string.");
     Assert.AreEqual(charge.Amount,0, "Amount is not zero.");
 }
 public void Add(Charge c)
 {
     charges.Add(c);
 }
예제 #6
0
        public void ClosePO()
        {
            WorkOrder wo1=new WorkOrder();
            WorkOrder wo2=new WorkOrder();

            wo1.Number="000001";
            wo2.Number="000002";

            Part p1=new Part();
            Part p2=new Part();
            Part p3=new Part();

            p1.Number="A";
            p1.VendorCost=15;

            p2.Number="B";
            p2.VendorCost=20;

            p3.Number="C";
            p3.VendorCost=25;

            vendor.Add(p1);
            vendor.Add(p2);
            vendor.Add(p3);

            po.Add(p1, wo1);
            po.Add(p2, wo1);
            po.Add(p3, wo2);

            Charge charge=new Charge();
            charge.Description="Freight";
            charge.Amount=10.50;

            Invoice invoice=new Invoice();
            invoice.Number="1234";
            invoice.Vendor=vendor;
            invoice.Add(charge);

            po.Invoice=invoice;

            po.Close();

            // one charge slip should be added to both work orders
            Assert.AreEqual(wo1.ChargeSlipCount,1, "First work order: ChargeSlipCount not 1.");
            Assert.AreEqual(wo2.ChargeSlipCount,1, "Second work order: ChargeSlipCount not 1.");

            ChargeSlip cs1=wo1.ChargeSlips[0];
            ChargeSlip cs2=wo2.ChargeSlips[0];

            // three charges should exist for charge slip #1: two parts and one freight charge
            Assert.AreEqual(cs1.PartCount + cs1.ChargeCount,3, "Charge slip 1: doesn't have three charges.");

            // the freight for CS1 should be 10.50 * (15+20)/(15+20+25) = 6.125
            Assert.AreEqual(cs1.Charges[0].Amount,6.125, "Charge slip 1: charge not the correct amount.");

            // two charges should exist for charge slip #2: one part and one freight charge
            Assert.AreEqual(cs2.PartCount + cs2.ChargeCount,2, "Charge slip 2: doesn't have two charges.");

            // the freight for CS2 should be 10.50 * 25/(15+20+25) = 4.375  (also = 10.50-6.125)
            Assert.AreEqual(cs2.Charges[0].Amount,4.375, "Charge slip 2: charge not the correct amount.");

            // while we have a unit test that verifies that parts are added to charge slips correctly,
            // we don't have a unit test to verify that the purchase order Close process does this
            // correctly.

            Part cs1p1=cs1.Parts[0];
            Part cs1p2=cs1.Parts[1];
            if (cs1p1.Number=="A")
            {
                Assert.AreEqual(cs1p1.VendorCost,15, "Charge slip 1, vendor cost not correct for part A.");
            }
            else if (cs1p1.Number=="B")
            {
                Assert.AreEqual(cs1p1.VendorCost,20, "Charge slip 1, vendor cost not correct for part B.");
            }
            else
            {
                throw(new IncorrectChargeSlipException());
            }

            Assert.IsTrue(cs1p1.Number != cs1p2.Number, "Charge slip part numbers are not unique.");

            if (cs1p2.Number=="A")
            {
                Assert.AreEqual(cs1p2.VendorCost,15, "Charge slip 1, vendor cost is not correct for part A.");
            }
            else if (cs1p2.Number=="B")
            {
                Assert.AreEqual(cs1p2.VendorCost,20, "Charge slip 1, vendor cost is not correct for part B.");
            }
            else
            {
                throw(new IncorrectChargeSlipException());
            }

            Assert.AreEqual(cs2.Parts[0].Number,"C", "Charge slip 2, part number is not correct.");
            Assert.AreEqual(cs2.Parts[0].VendorCost,25, "Charge slip 2, vendor cost is not correct for part C.");
        }
예제 #7
0
 public void UnassignedChargeNumber()
 {
     Charge charge=new Charge();
     invoice.Add(charge);
 }
예제 #8
0
 public void RetrieveCharge()
 {
     Charge charge=new Charge();
     charge.Description="123456";
     invoice.Add(charge);
     Charge c2=invoice.Charges[0];
     Assert.AreEqual(charge.Description,c2.Description, "Charge description does not match.");
 }
예제 #9
0
 public void AddCharge()
 {
     Charge charge=new Charge();
     charge.Description="Freight";
     invoice.Add(charge);
     Assert.AreEqual(invoice.ChargeCount,1, "Charge count wrong.");
 }
예제 #10
0
        public void SetChargeInfo()
        {
            Charge charge=new Charge();
            charge.Description="Freight";
            charge.Amount=8.50;

            Assert.AreEqual(charge.Description,"Freight", "Description is not set.");
            Assert.AreEqual(charge.Amount,8.50, "Amount is not set correctly.");
        }
예제 #11
0
 public void UnassignedCharge()
 {
     Charge charge=new Charge();
     chargeSlip.Add(charge);
 }