Ejemplo n.º 1
0
        public void TestFindHeaviestInATransportOf2WithEqualWeights()
        {// testing to find heaviest deliverable in a transport of size 1
            Transport t = new Transport();

            int[] deliverables = new int[2] {
                22, 35
            };
            Deliverable d;

            d = new Deliverable(22, 350, "Josephine", "Nieuwstraat", 2, "5688GE", "Eindhoven");
            t.AddDeliverable(d);
            d = new Deliverable(35, 350, "Cleopatra", "Klaverstraat", 2, "5372MX", "Eindhoven");
            t.AddDeliverable(d);

            d = t.FindHeaviestDeliverable();
            List <int> ids = new List <int>();
            int        max = 0;

            foreach (var item in t.Deliverables)
            {
                if (item.Weight >= max)
                {
                    ids.Add(item.ID);
                    max = item.Weight;
                }
            }
            Assert.AreEqual(d.Weight, max);
            CollectionAssert.AreEquivalent(deliverables, ids);
        }
Ejemplo n.º 2
0
        public void TestFindHeaviestInATransportOf2WithEqualWeights()
        {
            List <int> deliverableIds = new List <int>();
            List <int> actualIds      = new List <int>();

            actualIds.Add(22);
            actualIds.Add(35);
            actualIds.Add(35);

            Transport t = new Transport();

            Person      p1 = new Person("Josephine", "Nieuwstraat", 2, "5688GE", "Eindhoven");
            Deliverable d1 = new Deliverable(22, 350, p1);

            deliverableIds.Add(d1.ID);

            Assert.AreEqual(d1.ID, 22);
            t.AddDeliverable(d1);

            Person      p2 = new Person("Cleopatra", "Klaverstraat", 2, "5372MX", "Eindhoven");
            Deliverable d2 = new Deliverable(35, 350, p2);

            deliverableIds.Add(d2.ID);

            Assert.AreEqual(d2.ID, 35);
            t.AddDeliverable(d2);

            Deliverable dh = t.FindHeaviestDeliverable();

            deliverableIds.Add(dh.ID);
            Assert.AreEqual(dh.Weight, 350);
            Assert.AreEqual(dh.ID, 35);

            CollectionAssert.AreEqual(deliverableIds, actualIds);
        }
Ejemplo n.º 3
0
        public void TestAddDeliverablesWithDuplicateIDToATransport()
        {
            // arraing
            Deliverable d1        = new Deliverable(22, 350, "Josephine", "Nieuwstraat", 2, "5688GE", "Eindhoven");
            Deliverable d2        = new Deliverable(22, 450, "Josephine XX", "Oudestraat", 2, "5688HE", "Eindhoven");
            Transport   transport = new Transport();

            // act
            transport.AddDeliverable(d1);
            transport.AddDeliverable(d2);
        }
Ejemplo n.º 4
0
        public void TestAdd2DeliverablesToATransport()
        {
            // arraing
            Deliverable d1        = new Deliverable(22, 350, "Josephine", "Nieuwstraat", 2, "5688GE", "Eindhoven");
            Deliverable d2        = new Deliverable(23, 450, "Josephine XX", "Oudestraat", 2, "5688HE", "Eindhoven");
            Transport   transport = new Transport();

            // act
            transport.AddDeliverable(d1);
            transport.AddDeliverable(d2);
            // assert
            Assert.AreEqual(d1, transport.FindDeliverable(22));
            Assert.AreEqual(d2, transport.FindDeliverable(23));
        }
Ejemplo n.º 5
0
        public void TestAddDeliverablesWithDuplicateIDToATransport()
        {
            // Try to add 2 deliverables with the same id to a transport-object
            // An exception should be thrown

            Person      p1 = new Person("Josephine", "Nieuwstraat", 2, "5688GE", "Eindhoven");
            Deliverable d1 = new Deliverable(22, 350, p1);
            Person      p2 = new Person("Cleopatra", "Klaverstraat", 2, "5372MX", "Eindhoven");
            Deliverable d2 = new Deliverable(22, 750, p2);

            Transport t = new Transport();

            t.AddDeliverable(d1);
            t.AddDeliverable(d2);
        }
Ejemplo n.º 6
0
        public void TestFindHeaviestInATransportOf2()
        {// testing to find heaviest deliverable in a transport of size 1
            Transport t;

            t = new Transport();

            Deliverable d;

            d = new Deliverable(22, 350, "Josephine", "Nieuwstraat", 2, "5688GE", "Eindhoven");
            t.AddDeliverable(d);
            d = new Deliverable(35, 750, "Cleopatra", "Klaverstraat", 2, "5372MX", "Eindhoven");
            t.AddDeliverable(d);

            d = t.FindHeaviestDeliverable();
            Assert.AreEqual(d.Weight, 750);
            Assert.AreEqual(d.ID, 35);
        }
Ejemplo n.º 7
0
        public void TestAdd2DeliverablesToATransport()
        {
            Person      p1 = new Person("Josephine", "Nieuwstraat", 2, "5688GE", "Eindhoven");
            Deliverable d1 = new Deliverable(22, 350, p1);
            Transport   t  = new Transport();

            t.AddDeliverable(d1);
            Deliverable dr = t.FindDeliverable(22);

            Assert.AreEqual(dr.Iperson.Name, "Josephine");
            Assert.AreEqual(dr.Iperson.Street, "Nieuwstraat");
        }
Ejemplo n.º 8
0
        public void TestFindHeaviestInATransportOf1()
        {// testing to find heaviest deliverable in a transport of size 1
            Transport   t = new Transport();
            Person      p = new Person("Josephine", "Nieuwstraat", 2, "5688GE", "Eindhoven");
            Deliverable d = new Deliverable(22, 350, p);

            t.AddDeliverable(d);

            d = t.FindHeaviestDeliverable();

            Assert.AreEqual(d.Weight, 350);
            Assert.AreEqual(d.ID, 22);
        }
Ejemplo n.º 9
0
        public void TestAddADeliverableToATransport()
        {
            // Testing to add a deliverablen to a transport

            Person      p1 = new Person("Josephine", "Nieuwstraat", 2, "5688GE", "Eindhoven");
            Deliverable d1 = new Deliverable(22, 350, p1);
            Person      p2 = new Person("Cleopatra", "Klaverstraat", 2, "5372MX", "Eindhoven");
            Deliverable d2 = new Deliverable(35, 750, p2);

            Transport t = new Transport();

            t.AddDeliverable(d1);
            t.AddDeliverable(d2);

            Deliverable dr1 = t.FindDeliverable(22);

            Assert.AreEqual(dr1.Iperson.Name, "Josephine");
            Assert.AreEqual(dr1.Iperson.Street, "Nieuwstraat");

            Deliverable dr2 = t.FindDeliverable(35);

            Assert.AreEqual(dr2.Iperson.Name, "Cleopatra");
            Assert.AreEqual(dr2.Iperson.Street, "Klaverstraat");
        }
Ejemplo n.º 10
0
        public void TestAddADeliverableToATransport()
        {// testing to  add a deliverablen to a transport
            Deliverable d1;

            d1 = new Deliverable(22, 350, "Josephine", "Nieuwstraat", 2, "5688GE", "Eindhoven");
            Transport t;

            t = new Transport();
            t.AddDeliverable(d1);

            Deliverable d2 = t.FindDeliverable(22);

            Assert.AreEqual(d2.Name, "Josephine");
            Assert.AreEqual(d2.Street, "Nieuwstraat");
        }