Add unit tests to expose problem with setting null strings in tags
authorAndy Allan <andy@gravitystorm.co.uk>
Sun, 3 Apr 2011 14:38:28 +0000 (15:38 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Sun, 3 Apr 2011 14:38:28 +0000 (15:38 +0100)
tests/src/AllHalcyonTests.as
tests/src/net/systemeD/halcyon/connection/actions/SetTagActionTest.as [new file with mode: 0644]

index cc4673a..d43f584 100644 (file)
@@ -3,6 +3,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.halcyon.connection.actions.SetTagActionTest;
     import net.systemeD.potlatch2.mapfeatures.FeatureTest;
 
     [Suite]
@@ -12,6 +13,7 @@ package {
         public var nodeTest:NodeTest;
         public var joinNodeActionTest:JoinNodeActionTest;
         public var addMemberToRelationActionTest:AddMemberToRelationActionTest;
+        public var setTagActionTest:SetTagActionTest;
 
         //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/SetTagActionTest.as b/tests/src/net/systemeD/halcyon/connection/actions/SetTagActionTest.as
new file mode 100644 (file)
index 0000000..7ca18ec
--- /dev/null
@@ -0,0 +1,36 @@
+package net.systemeD.halcyon.connection.actions {
+
+    import org.flexunit.Assert;
+    import net.systemeD.halcyon.connection.actions.SetTagAction;
+    import net.systemeD.halcyon.connection.UndoableAction;
+    import net.systemeD.halcyon.connection.Entity;
+    import net.systemeD.halcyon.connection.Connection;
+
+    public class SetTagActionTest {
+
+        [Before]
+        public function setUp():void {
+            //Instantiate the connection first to prevent errors
+            Connection.getConnection();
+        }
+
+        [Test]
+        public function setTag():void {
+            var e:Entity = new Entity(1,1,{},true,1,"");
+            var action:UndoableAction = new SetTagAction(e, "foo", "bar");
+            action.doAction();
+
+            Assert.assertEquals("bar", e.getTag("foo"));
+        }
+
+        [Test]
+        public function setNullTag():void {
+            var e:Entity = new Entity(1,1,{foo: "bar"},true,1,"");
+            var action:UndoableAction = new SetTagAction(e, "foo", null);
+            action.doAction();
+
+            Assert.assertNull(e.getTag("foo"));
+        }
+
+    }
+}
\ No newline at end of file