Add tests for AddMemberToRelationAction, but I can't get the main one working and...
authorAndy Allan <andy@gravitystorm.co.uk>
Tue, 29 Mar 2011 18:28:46 +0000 (19:28 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Sat, 2 Apr 2011 11:15:28 +0000 (12:15 +0100)
tests/src/AllHalcyonTests.as
tests/src/net/systemeD/halcyon/connection/actions/AddMemberToRelationActionTest.as [new file with mode: 0644]

index 7b26996..cc4673a 100644 (file)
@@ -2,6 +2,7 @@ package {
 
     import net.systemeD.halcyon.connection.NodeTest;
     import net.systemeD.halcyon.connection.actions.JoinNodeActionTest;
+    import net.systemeD.halcyon.connection.actions.AddMemberToRelationActionTest;
     import net.systemeD.potlatch2.mapfeatures.FeatureTest;
 
     [Suite]
@@ -10,6 +11,7 @@ package {
 
         public var nodeTest:NodeTest;
         public var joinNodeActionTest:JoinNodeActionTest;
+        public var addMemberToRelationActionTest:AddMemberToRelationActionTest;
 
         //Potlatch2 tests. If anyone wants to separate these out, and / or rename the suite, feel free
         public var featureTest:FeatureTest;
diff --git a/tests/src/net/systemeD/halcyon/connection/actions/AddMemberToRelationActionTest.as b/tests/src/net/systemeD/halcyon/connection/actions/AddMemberToRelationActionTest.as
new file mode 100644 (file)
index 0000000..533fa78
--- /dev/null
@@ -0,0 +1,42 @@
+package net.systemeD.halcyon.connection.actions {
+
+    import org.flexunit.Assert;
+    import net.systemeD.halcyon.connection.actions.AddMemberToRelationAction;
+    import net.systemeD.halcyon.connection.Relation;
+    import net.systemeD.halcyon.connection.Node;
+    import net.systemeD.halcyon.connection.RelationMember;
+    import net.systemeD.halcyon.connection.UndoableAction;
+    import net.systemeD.halcyon.connection.*;
+
+    public class AddMemberToRelationActionTest {
+
+        [Test]
+        public function addMember():void {
+
+            var n:Node = new Node(1,1,{},true,5,10);
+
+            var rel:Relation = new Relation(1,1,{},true,[]);
+            var member:RelationMember = new RelationMember(n, "foo");
+
+            //This throws an error, but JoinNodeActionTest doesn't. Why?
+
+            //rel.appendMember(member, function(action:UndoableAction):void { action.doAction(); })
+            //Assert.assertEquals(rel.length,1);
+
+            //Assert.assertNotNull(Connection.getConnectionInstance()) <- this fails, and is the cause of the above failing. Why?
+        }
+
+        [Test]
+        public function spliceStuff():void {
+
+            var arr:Array = ["a", "b", "c", "d"];
+            Assert.assertEquals(arr.length, 4);
+
+            arr.splice(-1, 0, "e");
+            Assert.assertEquals(arr.length, 5);
+
+            arr.splice(-1, 1);
+            Assert.assertEquals(arr.length, 4);
+        }
+    }
+}
\ No newline at end of file