Ejemplo n.º 1
0
 public void AddPart()
 {
     Part part=new Part();
     part.Number="VOD-13-33P";
     chargeSlip.Add(part);
     Assert.AreEqual(chargeSlip.PartCount,1, "PartCount is wrong.");
 }
 public void Add(Part p)
 {
     if (p.Number=="")
     {
         throw(new UnassignedPartException());
     }
     parts.Add(p);
 }
Ejemplo n.º 3
0
        public void Add(Part p)
        {
            if (p==null)
            {
                throw(new InvalidPartException());
            }

            if (p.Number=="")
            {
                throw(new UnassignedPartException());
            }

            if (parts.Contains(p.Number))
            {
                throw(new DuplicatePartException());
            }

            parts.Add(p.Number, p);
            partsArray.Add(p);
        }
Ejemplo n.º 4
0
 public void Add(Part p)
 {
     parts.Add(p);
 }
Ejemplo n.º 5
0
 public void RetrievePart()
 {
     Part part=new Part();
     part.Number="VOD-13-33P";
     chargeSlip.Add(part);
     Part p2=chargeSlip.Parts[0];
     Assert.AreEqual(p2.Number,part.Number, "Part numbers do not match.");
 }
Ejemplo n.º 6
0
        void CreateTestParts()
        {
            Part part1=new Part();
            part1.Number="BOD-13-25P";
            vendor.Add(part1);

            Part part2=new Part();
            part2.Number="BOD-13-33P";
            vendor.Add(part2);
        }
Ejemplo n.º 7
0
        public void SetVendorInfo()
        {
            Part part=new Part();
            part.Number="FIG 4RAC #R11T";
            part.VendorCost=12.50;
            part.Taxable=true;
            part.InternalCost=13.00;
            part.Markup=2.0;

            Assert.AreEqual(part.Number,"FIG 4RAC #R11T", "Number did not get set.");
            Assert.AreEqual(part.VendorCost,12.50, "VendorCost did not get set.");
            Assert.AreEqual(part.Taxable,true, "Taxable did not get set.");
            Assert.AreEqual(part.InternalCost,13.00, "InternalCost did not get set.");
            Assert.AreEqual(part.Markup,2.0, "Markup did not get set.");
        }
Ejemplo n.º 8
0
 public bool Find(Part p)
 {
     return parts.Contains(p.Number);
 }
Ejemplo n.º 9
0
 public void Add(Part p, WorkOrder wo)
 {
     parts.Add(p, wo);
 }
Ejemplo n.º 10
0
 public void UnassignedPartNumber()
 {
     WorkOrder workOrder=new WorkOrder();
     workOrder.Number="123456";
     Part part=new Part();
     po.Add(part, workOrder);
 }
Ejemplo n.º 11
0
 public void AddUnassignedPart()
 {
     Part part=new Part();
     chargeSlip.Add(part);
 }
Ejemplo n.º 12
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.");
        }
Ejemplo n.º 13
0
 public void AddPartNotFromVendor()
 {
     WorkOrder workOrder=new WorkOrder();
     workOrder.Number="123456";
     Part part=new Part();
     part.Number="131133";
     po.Add(part, workOrder);
 }
Ejemplo n.º 14
0
 public void AddPart()
 {
     WorkOrder workOrder=new WorkOrder();
     workOrder.Number="123456";
     Part part=new Part();
     part.Number="112233";
     vendor.Add(part);
     po.Add(part, workOrder);
     WorkOrder wo2;
     Part p2;
     po.GetPart(0, out p2, out wo2);
     Assert.AreEqual(p2.Number,part.Number, "Part number does not match.");
     Assert.AreEqual(wo2.Number,workOrder.Number, "Work order number does not match.");
 }
Ejemplo n.º 15
0
 public WorkOrder this[Part p]
 {
     get {return parts[p] as WorkOrder;}
 }
Ejemplo n.º 16
0
 public void Add(string partNumber, Part p)
 {
     parts.Add(partNumber, p);
 }
Ejemplo n.º 17
0
 public void UnassignedWorkOrderNumber()
 {
     WorkOrder workOrder=new WorkOrder();
     Part part=new Part();
     part.Number="112233";
     po.Add(part, workOrder);
 }
Ejemplo n.º 18
0
 public void DuplicateParts()
 {
     Part part=new Part();
     part.Number="Same Part Number";
     vendor.Add(part);
     vendor.Add(part);
 }
Ejemplo n.º 19
0
 public void UnassignedPartNumber()
 {
     Part part=new Part();
     vendor.Add(part);
 }
        public void PartConstructor()
        {
            part1=new Part();
            Assert.AreEqual(part1.VendorCost,0, "VendorCost is not zero.");
            Assert.AreEqual(part1.Taxable,false, "Taxable is not false.");
            Assert.AreEqual(part1.InternalCost,0, "InternalCost is not zero.");
            Assert.AreEqual(part1.Markup,0, "Markup is not zero.");
            Assert.AreEqual(part1.Number,"", "Number is not an empty string.");

            part2=new Part();
            part3=new Part();
        }
Ejemplo n.º 21
0
 public void ConstructorInitialization()
 {
     Part part=new Part();
     Assert.AreEqual(part.VendorCost,0, "VendorCost is not zero.");
     Assert.AreEqual(part.Taxable,false, "Taxable is not false.");
     Assert.AreEqual(part.InternalCost,0, "InternalCost is not zero.");
     Assert.AreEqual(part.Markup,0, "Markup is not zero.");
     Assert.AreEqual(part.Number,"", "Number is not an empty string.");
 }