Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Scenes.Tests.Controls TextBoxTests
Namespace: DeltaEngine.Scenes.Tests.Controls
Assembly: DeltaEngine.Scenes.Tests (in DeltaEngine.Scenes.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The TextBoxTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
TextBoxTests | Initializes a new instance of the TextBoxTests class |
Methods
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test, CloseAfterFirstFrame] public void DefaultsToEnabled() { Assert.IsTrue(topTextBox.IsEnabled); }
[Test, CloseAfterFirstFrame] public void ClickingTextBoxGivesItFocus() { if (!IsMockResolver) return; //ncrunch: no coverage Assert.IsFalse(topTextBox.State.HasFocus); PressAndReleaseMouse(Vector2D.One); Assert.IsFalse(topTextBox.State.HasFocus); PressAndReleaseMouse(Top.Center); Assert.IsTrue(topTextBox.State.HasFocus); }
[Test, CloseAfterFirstFrame] public void ClickingOneTextBoxCausesOtherTextBoxToLoseFocus() { if (!IsMockResolver) return; //ncrunch: no coverage PressAndReleaseMouse(Top.Center); Assert.IsTrue(topTextBox.State.HasFocus); Assert.IsFalse(bottomTextBox.State.HasFocus); PressAndReleaseMouse(Bottom.Center); Assert.IsFalse(topTextBox.State.HasFocus); Assert.IsTrue(bottomTextBox.State.HasFocus); Assert.AreEqual(Color.Gray, topTextBox.Color); Assert.AreEqual(Color.LightGray, bottomTextBox.Color); }
[Test, CloseAfterFirstFrame] public void TypingHasNoEffectIfTextBoxDoesNotHaveFocus() { topTextBox.Text = ""; PressKey(Key.A); Assert.AreEqual("", topTextBox.Text); }
[Test, CloseAfterFirstFrame] public void TypingGoesIntoTheTextBoxWithFocus() { if (!IsMockResolver) return; //ncrunch: no coverage topTextBox.Text = ""; bottomTextBox.Text = ""; PressAndReleaseMouse(Bottom.Center); PressKeys(); Assert.AreEqual("", topTextBox.Text); Assert.AreEqual("a 2", bottomTextBox.Text); }
[Test, ApproveFirstFrameScreenshot] public void RenderOneEnabledAndOneDisabledTextBox() { bottomTextBox.IsEnabled = false; AdvanceTimeAndUpdateEntities(); Assert.AreEqual(Color.Gray, topTextBox.Color); Assert.AreEqual(Color.DarkGray, bottomTextBox.Color); }
[Test, CloseAfterFirstFrame] public void ClickingTextBoxDoesNotGivesItFocusIfItIsDisabled() { topTextBox.IsEnabled = false; PressAndReleaseMouse(Top.Center); Assert.IsFalse(topTextBox.State.HasFocus); }
[Test, CloseAfterFirstFrame] public void TypingDoesNotGoIntoADisabledTextBox() { bottomTextBox.IsEnabled = false; bottomTextBox.Text = ""; PressAndReleaseMouse(Bottom.Center); PressKeys(); Assert.AreEqual("", bottomTextBox.Text); }
[Test] public void RenderTextBoxAttachedToMouse() { new Command(point => topTextBox.DrawArea = //ncrunch: no coverage Rectangle.FromCenter(point, topTextBox.DrawArea.Size)).Add(new MouseMovementTrigger()); }
[Test, CloseAfterFirstFrame] public void SaveAndLoad() { var stream = BinaryDataExtensions.SaveToMemoryStream(topTextBox); var loadedTextBox = (TextBox)stream.CreateFromMemoryStream(); Assert.AreEqual(Top, loadedTextBox.DrawArea); Assert.AreEqual("Hello", loadedTextBox.Text); Assert.AreEqual(2, loadedTextBox.RenderLayer); Assert.IsTrue(loadedTextBox.State.CanHaveFocus); Assert.AreEqual(topTextBox.children.Count, loadedTextBox.children.Count); }
[Test] public void DrawLoadedTextBox() { topTextBox.Text = "Original"; bottomTextBox.IsActive = false; var stream = BinaryDataExtensions.SaveToMemoryStream(topTextBox); var loadedTextBox = (TextBox)stream.CreateFromMemoryStream(); loadedTextBox.Text = "Loaded"; loadedTextBox.DrawArea = loadedTextBox.DrawArea.Move(0.0f, 0.15f); }
[Test] public void ChangingFontTextChangesChild() { var text = new FontText(Font.Default, "Hello", Rectangle.HalfCentered); topTextBox.Set(text); Assert.AreEqual(text, topTextBox.children[0].Entity2D); }
[Test] public void CheckRightKeys() { var textBox = new TextBox(Rectangle.One, "test"); textBox.IsEnabled = true; textBox.State.HasFocus = true; new Command(() => textBox.Text = keyboard.HandleInput(textBox.Text)).Add( new KeyTrigger(Key.None, State.Released)); }
See Also