public void CurrenteItemに不正なアイテムを代入した場合は例外() { var window = new EPuzzleWindow(); var testState = new Fish.eigotest.TestState(window); Assert.Null(testState.CurrentItem); var b0 = new EigoTestButtonItem() { Left = 100, Top = 100, Width = 10, Height = 10, }; Assert.Null(b0.GetState()); testState.Items.Add(b0); window.State = testState; Assert.AreSame(b0, testState.CurrentItem); b0.IsClickable = false; Assert.Throws<ArgumentException>(() => { testState.CurrentItem = b0; }); b0.IsClickable = true; testState.Items.Remove(b0); Assert.Throws<ArgumentException>(() => { testState.CurrentItem = b0; }); }
public void 資格のなくなったCurrentItemを変更する() { var window = new EPuzzleWindow(); var testState = new Fish.eigotest.TestState(window); Assert.Null(testState.CurrentItem); var b0 = new EigoTestButtonItem() { Position = DrawingObjectPosition.Absolute, Left = 100, Top = 100, Width = 10, Height = 10, }; Assert.Null(b0.GetState()); testState.Items.Add(b0); window.State = testState; Assert.AreSame(b0, testState.CurrentItem); Assert.Null(testState.DrawingObjectRoot.Parent); Assert.AreSame(testState, testState.DrawingObjectRoot.GetState()); Assert.AreSame(testState, b0.GetState()); testState.Items.RemoveAt(0); Assert.AreEqual(0, testState.Items.Count()); Assert.Null(testState.CurrentItem); var b1 = new EigoTestButtonItem() { Position = DrawingObjectPosition.Absolute, Left = 200, Top = 100, Width = 10, Height = 10, }; testState.Items.Add(b0); testState.Items.Add(b1); Assert.AreSame(b0, testState.CurrentItem); b0.IsClickable = false; Assert.AreSame(b1, testState.CurrentItem); testState.Items.Remove(b1); Assert.Null(testState.CurrentItem); // 同じコレクション内のアイテムを優先する b0.IsClickable = true; var b2 = new EigoTestButtonItem() { Position = DrawingObjectPosition.Absolute, Left = 300, Top = 100, Width = 10, Height = 10, }; var container = new DrawingObjectContainer() { Position = DrawingObjectPosition.Absolute, Left = 200, Top = 100, Width = 500, Height = 500, }; container.Items.Add(b1); container.Items.Add(b2); testState.Items.Add(container); Assert.AreSame(b0, testState.CurrentItem); testState.CurrentItem = b1; b1.IsClickable = false; Assert.AreSame(b2, testState.CurrentItem); // 同じコレクション内のアイテムで座標が近いものを優先する b1.IsClickable = true; b2.IsClickable = true; var b3 = new EigoTestButtonItem() { Position = DrawingObjectPosition.Absolute, Left = 301, Top = 100, Width = 10, Height = 10, }; container.Items.Add(b3); testState.CurrentItem = b2; b2.IsClickable = false; Assert.AreSame(b3, testState.CurrentItem); // 同じコレクション内になければすべての先頭から選択する b1.IsClickable = false; b2.IsClickable = false; b3.IsClickable = false; Assert.AreSame(b0, testState.CurrentItem); }