public void Add() { #region ... SPDisplayObject child1 = new SPQuad(32.0f, 32.0f); SPDisplayObject child2 = new SPQuad(32.0f, 32.0f); SPDisplayObject child3 = new SPQuad(32.0f, 32.0f); SPDisplayObject child4 = new SPQuad(32.0f, 32.0f); Assert.True(child1 != child2); Assert.True(child2 != child3); SPDisplayObjectContainer container = new SPStage(); container.Add(child1); Assert.True(container.Count == 1); Assert.True(container.IndexOf(child1) == 0); Assert.True(container.IndexOf(child2) == -1); Assert.True(container[0] == child1); Assert.False(container[0] == child2); Assert.True(container.Contains(child1)); Assert.False(container.Contains(child2)); container.Add(child3); container.Add(child2); Assert.True(container.Count == 3); Assert.True(container.IndexOf(child1) == 0); Assert.True(container.IndexOf(child2) == 2); Assert.True(container.IndexOf(child3) == 1); Assert.True(container[0] == child1); Assert.True(container[1] == child3); Assert.True(container[2] == child2); Assert.True(container.Contains(child1)); Assert.True(container.Contains(child2)); Assert.True(container.Contains(child3)); container[1] = child4; Assert.True(container.Contains(child1)); Assert.True(container.Contains(child2)); Assert.False(container.Contains(child3)); Assert.True(container.Contains(child4)); Assert.True(container.Count == 3); #endregion }
public void Swap() { #region ... SPDisplayObjectContainer container = new SPStage(); SPDisplayObject obj1 = new SPQuad(32.0f, 32.0f); SPDisplayObject obj2 = new SPQuad(32.0f, 32.0f); SPDisplayObject obj3 = new SPQuad(32.0f, 32.0f); SPDisplayObject obj4 = new SPQuad(32.0f, 32.0f); container.Add(obj1); container.Add(obj2); container.Add(obj3); container.Add(obj4); container.Swap(obj1, obj4); container.Swap(2, 1); Assert.True(container.IndexOf(obj1) == 3); Assert.True(container.IndexOf(obj2) == 2); Assert.True(container.IndexOf(obj3) == 1); Assert.True(container.IndexOf(obj4) == 0); #endregion }
public void MoveAndRemove() { #region ... SPDisplayObjectContainer container = new SPStage(); SPDisplayObject obj1 = new SPQuad(32.0f, 32.0f); SPDisplayObject obj2 = new SPQuad(32.0f, 32.0f); SPDisplayObject obj3 = new SPQuad(32.0f, 32.0f); SPDisplayObject obj4 = new SPQuad(32.0f, 32.0f); container.Add(obj1); container.Add(obj2); container.Add(obj3); container.Add(obj4); Assert.True(container.Count == 4); Assert.True(container.IndexOf(obj4) == 3); container.Move(1, obj4); Assert.True(container.Count == 4); Assert.True(container.IndexOf(obj4) == 1); Assert.True(container.IndexOf(obj2) == 2); Assert.True(container.Remove(obj3)); Assert.False(container.Remove(obj3)); Assert.True(container.Count == 3); Assert.False(container.Contains(obj3)); container.RemoveAt(1); Assert.True(container.Count == 2); Assert.False(container.Contains(obj4)); container.Clear(); Assert.True(container.Count == 0); #endregion }
public void Insert() { #region ... SPDisplayObject child1 = new SPQuad(32.0f, 32.0f); SPDisplayObject child2 = new SPQuad(32.0f, 32.0f); SPDisplayObject child3 = new SPQuad(32.0f, 32.0f); SPDisplayObjectContainer container = new SPStage(); container.Add(child1); container.Add(child3); container.Insert(1, child2); Assert.True(container.Count == 3); Assert.True(container.IndexOf(child1) == 0); Assert.True(container.IndexOf(child2) == 1); Assert.True(container.IndexOf(child3) == 2); #endregion }