Example #1
0
        public void Knot_Move_Test()
        {
            Edge[] edges = new Edge[] {
                Edge.Up, Edge.Left, Edge.Down, Edge.Right
            };
            string name = "test";

            KnotMetaData metaData = new KnotMetaData (name: name, countEdges: () => edges.Length);
            Knot knot = new Knot (metaData, edges);

            knot.AddToSelection (edges [1]); // Edge.Left

            Log.Debug ("Selected: ", knot.SelectedEdges);

            bool success;

            success = knot.IsValidDirection (direction: Direction.Left);
            Assert.IsFalse (success);
            success = knot.IsValidDirection (direction: Direction.Right);
            Assert.IsFalse (success);
            success = knot.IsValidDirection (direction: Direction.Up);
            Assert.IsTrue (success);
            success = knot.IsValidDirection (direction: Direction.Down);
            Assert.IsTrue (success);
            success = knot.IsValidDirection (direction: Direction.Forward);
            Assert.IsTrue (success);
            success = knot.IsValidDirection (direction: Direction.Backward);
            Assert.IsTrue (success);

            success = knot.Move (direction: Direction.Down, distance: 1);
            Assert.IsFalse (success, "Nicht möglich! Knoten würde zu zwei Kanten zusammenfallen!");

            success = knot.Move (direction: Direction.Left, distance: 1);
            Assert.IsFalse (success, "Ungültige Richtung!");

            success = knot.Move (direction: Direction.Right, distance: 1);
            Assert.IsFalse (success, "Ungültige Richtung!");

            // nach oben schieben (1x)
            success = knot.Move (direction: Direction.Up, distance: 1);
            Assert.IsTrue (success, "Gültige Richtung!");

            Assert.AreEqual (knot.Count (), edges.Length + 2, "Knotenlänge nach Verschiebung #1");

            // noch mal nach oben schieben (2x)
            success = knot.Move (direction: Direction.Up, distance: 2);

            Assert.AreEqual (knot.Count (), edges.Length + 2 * 3, "Knotenlänge nach Verschiebung #2");

            // wieder nach unten schieben (3x)
            success = knot.Move (direction: Direction.Down, distance: 3);
            Assert.IsTrue (success, "Gültige Richtung!");

            Assert.AreEqual (knot.Count (), edges.Length, "Knotenlänge nach Verschiebung #3");

            success = knot.Move (direction: Direction.Zero, distance: 3);
            Assert.AreEqual (knot.Count (), edges.Length, "Null-Move");
            success = knot.Move (direction: Direction.Left, distance: 0);
            Assert.AreEqual (knot.Count (), edges.Length, "Null-Move");
            success = knot.Move (direction: Direction.Zero, distance: 0);
            Assert.AreEqual (knot.Count (), edges.Length, "Null-Move");
        }