예제 #1
0
        public void Find8SlotsSameSize()
        {
            Topology t = new Topology();

            t.AddDevice("D1");
            t.AddDevice("D2");

            t.AddConnection("C1", "D1", "D2", 80);

            t.AddLink("L1", "D1", "D2", 10);
            t.AddLink("L2", "D1", "D2", 10);
            t.AddLink("L3", "D1", "D2", 10);
            t.AddLink("L4", "D1", "D2", 10);
            t.AddLink("L5", "D1", "D2", 10);
            t.AddLink("L6", "D1", "D2", 10);
            t.AddLink("L7", "D1", "D2", 10);
            t.AddLink("L8", "D1", "D2", 10);

            t.AllocateLinksPaths();
            t.AllocateSlots();

            Assert.AreEqual(1, t.GetLink("L1").mainPath.Count);
            Assert.AreEqual(t.GetDevice("D1"), t.GetLink("L1").mainPath[0].source);
            Assert.AreEqual(t.GetDevice("D2"), t.GetLink("L1").mainPath[0].destination);
            Assert.AreEqual(8, t.GetConnection("C1").slots.Count);
            Assert.AreEqual(t.GetLink("L1"), t.GetConnection("C1").slots[0].slotOWner);
            Assert.AreEqual(t.GetLink("L2"), t.GetConnection("C1").slots[1].slotOWner);
            Assert.AreEqual(t.GetLink("L3"), t.GetConnection("C1").slots[2].slotOWner);
            Assert.AreEqual(t.GetLink("L4"), t.GetConnection("C1").slots[3].slotOWner);
            Assert.AreEqual(t.GetLink("L5"), t.GetConnection("C1").slots[4].slotOWner);
            Assert.AreEqual(t.GetLink("L6"), t.GetConnection("C1").slots[5].slotOWner);
            Assert.AreEqual(t.GetLink("L7"), t.GetConnection("C1").slots[6].slotOWner);
            Assert.AreEqual(t.GetLink("L8"), t.GetConnection("C1").slots[7].slotOWner);
        }
예제 #2
0
        public void TwoWayPathFind()
        {
            Topology t = new Topology();

            t.AddDevice("D1");
            t.AddDevice("D2");

            t.AddConnection("C1", "D1", "D2", 10);
            t.AddConnection("C2", "D2", "D1", 10);

            t.AddLink("L1", "D1", "D2", 10);
            t.AddLink("L2", "D2", "D1", 10);

            t.AllocateLinksPaths();

            Assert.AreEqual(1, t.GetLink("L1").mainPath.Count);
            Assert.AreEqual(t.GetDevice("D1"), t.GetLink("L1").mainPath[0].source);
            Assert.AreEqual(t.GetDevice("D2"), t.GetLink("L1").mainPath[0].destination);

            Assert.AreEqual(1, t.GetLink("L2").mainPath.Count);
            Assert.AreEqual(t.GetDevice("D2"), t.GetLink("L2").mainPath[0].source);
            Assert.AreEqual(t.GetDevice("D1"), t.GetLink("L2").mainPath[0].destination);
        }
예제 #3
0
        public void SimpleSlotFind()
        {
            Topology t = new Topology();

            t.AddDevice("D1");
            t.AddDevice("D2");

            t.AddConnection("C1", "D1", "D2", 10);

            t.AddLink("L1", "D1", "D2", 10);

            t.AllocateLinksPaths();
            t.AllocateSlots();

            Assert.AreEqual(1, t.GetLink("L1").mainPath.Count);
            Assert.AreEqual(t.GetDevice("D1"), t.GetLink("L1").mainPath[0].source);
            Assert.AreEqual(t.GetDevice("D2"), t.GetLink("L1").mainPath[0].destination);
            Assert.AreEqual(1, t.GetConnection("C1").slots.Count);
            Assert.AreEqual(t.GetLink("L1"), t.GetConnection("C1").slots[0].slotOWner);
        }
예제 #4
0
        public void ForbiddenSlotConstraintTest()
        {
            Topology t = new Topology();

            t.AddDevice("D1");
            t.AddDevice("D2");

            t.AddConnection("C1", "D1", "D2", 20);

            t.AddLink("L1", "D1", "D2", 10);

            t.AddForbiddenSlotConstraint("Constraint-1", "D1", 0, 2);

            t.AllocateLinksPaths();
            t.AllocateSlots();

            Assert.AreEqual(1, t.GetLink("L1").mainPath.Count);
            Assert.AreEqual(t.GetDevice("D1"), t.GetLink("L1").mainPath[0].source);
            Assert.AreEqual(t.GetDevice("D2"), t.GetLink("L1").mainPath[0].destination);
            Assert.AreEqual(2, t.GetConnection("C1").slots.Count);
            Assert.AreEqual(Slot.State.FORBIDDEN, t.GetConnection("C1").slots[0].state);
            Assert.AreEqual("Constraint-1", t.GetConnection("C1").slots[0].constraintName);
            Assert.AreEqual(Slot.State.TAKEN, t.GetConnection("C1").slots[1].state);
            Assert.AreEqual(t.GetLink("L1"), t.GetConnection("C1").slots[1].slotOWner);
        }