Add unit tests to expose problem with setting null strings in tags
[potlatch2.git] / tests / src / net / systemeD / halcyon / connection / actions / SetTagActionTest.as
1 package net.systemeD.halcyon.connection.actions {
2
3     import org.flexunit.Assert;
4     import net.systemeD.halcyon.connection.actions.SetTagAction;
5     import net.systemeD.halcyon.connection.UndoableAction;
6     import net.systemeD.halcyon.connection.Entity;
7     import net.systemeD.halcyon.connection.Connection;
8
9     public class SetTagActionTest {
10
11         [Before]
12         public function setUp():void {
13             //Instantiate the connection first to prevent errors
14             Connection.getConnection();
15         }
16
17         [Test]
18         public function setTag():void {
19             var e:Entity = new Entity(1,1,{},true,1,"");
20             var action:UndoableAction = new SetTagAction(e, "foo", "bar");
21             action.doAction();
22
23             Assert.assertEquals("bar", e.getTag("foo"));
24         }
25
26         [Test]
27         public function setNullTag():void {
28             var e:Entity = new Entity(1,1,{foo: "bar"},true,1,"");
29             var action:UndoableAction = new SetTagAction(e, "foo", null);
30             action.doAction();
31
32             Assert.assertNull(e.getTag("foo"));
33         }
34
35     }
36 }