Check that relation appending member and setting member end up in the right place
authorAndy Allan <andy@gravitystorm.co.uk>
Sat, 2 Apr 2011 14:55:35 +0000 (15:55 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Sat, 2 Apr 2011 15:08:51 +0000 (16:08 +0100)
tests/src/net/systemeD/halcyon/connection/actions/AddMemberToRelationActionTest.as

index f99ef9b..df86b4f 100644 (file)
@@ -20,7 +20,7 @@ package net.systemeD.halcyon.connection.actions {
 
             //Instantiate the connection first to prevent errors
             Connection.getConnection();
-            rel.appendMember(member, function(action:UndoableAction):void { action.doAction(); })
+            rel.appendMember(member, function(action:UndoableAction):void { action.doAction(); });
             Assert.assertEquals(1, rel.length);
 
         }
@@ -38,5 +38,41 @@ package net.systemeD.halcyon.connection.actions {
             Assert.assertEquals("e", arr[3]);
             Assert.assertEquals("d", arr[4]);
         }
+
+        [Test]
+        public function appendMember():void {
+            var n:Node = new Node(1,1,{},true,5,10);
+            var n2:Node = new Node(2,1,{},true,5,10);
+            var n3:Node = new Node(3,1,{},true,5,10);
+
+            var member1:RelationMember = new RelationMember(n, "first");
+            var member2:RelationMember = new RelationMember(n2, "second");
+            var member3:RelationMember = new RelationMember(n3, "third");
+
+            var rel:Relation = new Relation(1,1,{},true, [member1, member2]);
+            Assert.assertEquals(2, rel.length);
+
+            rel.appendMember(member3, function(action:UndoableAction):void { action.doAction(); });
+            Assert.assertEquals(member3, rel.getMember(2));
+        }
+
+        [Test]
+        public function setMember():void {
+            var n:Node = new Node(1,1,{},true,5,10);
+            var n2:Node = new Node(2,1,{},true,5,10);
+            var n3:Node = new Node(3,1,{},true,5,10);
+
+            var member1:RelationMember = new RelationMember(n, "first");
+            var member2:RelationMember = new RelationMember(n2, "second");
+            var member3:RelationMember = new RelationMember(n3, "third");
+
+            var rel:Relation = new Relation(1,1,{},true, [member1, member2]);
+            Assert.assertEquals(2, rel.length);
+
+            rel.setMember(1, member3, function(action:UndoableAction):void { action.doAction(); });
+            Assert.assertEquals(member3, rel.getMember(1));
+
+            Assert.assertEquals(2, rel.length);
+        }
     }
 }
\ No newline at end of file