A little splice test to demonstrate the bug that the unit test will cover
[potlatch2.git] / tests / src / net / systemeD / halcyon / connection / actions / AddMemberToRelationActionTest.as
1 package net.systemeD.halcyon.connection.actions {
2
3     import org.flexunit.Assert;
4     import net.systemeD.halcyon.connection.actions.AddMemberToRelationAction;
5     import net.systemeD.halcyon.connection.Relation;
6     import net.systemeD.halcyon.connection.Node;
7     import net.systemeD.halcyon.connection.RelationMember;
8     import net.systemeD.halcyon.connection.UndoableAction;
9     import net.systemeD.halcyon.connection.*;
10
11     public class AddMemberToRelationActionTest {
12
13         [Test]
14         public function addMember():void {
15
16             var n:Node = new Node(1,1,{},true,5,10);
17
18             var rel:Relation = new Relation(1,1,{},true,[]);
19             var member:RelationMember = new RelationMember(n, "foo");
20
21             //Instantiate the connection first to prevent errors
22             Connection.getConnection();
23             rel.appendMember(member, function(action:UndoableAction):void { action.doAction(); })
24             Assert.assertEquals(1, rel.length);
25
26         }
27
28         [Test]
29         public function spliceStuff():void {
30
31             // create an array
32             var arr:Array = ["a", "b", "c", "d"];
33             Assert.assertEquals(4, arr.length);
34
35             // doesn't actually splice onto the end, inserts at position 4
36             arr.splice(-1, 0, "e");
37             Assert.assertEquals(5, arr.length);
38             Assert.assertEquals("e", arr[3]);
39             Assert.assertEquals("d", arr[4]);
40         }
41     }
42 }