public void CanFocus_Set_EventOnlyOnChange() { using var stubbedWindow = new StubbedWindow(); var textController = new StubbedConsoleTextController(); using var sut = new ConControls.Controls.Button(stubbedWindow, textController); int raised = 0; sut.CanFocusChanged += (sender, e) => raised++; sut.CanFocus = true; sut.CanFocus.Should().BeTrue(); raised.Should().Be(1); // base value is false before sut.CanFocus = true; sut.CanFocus.Should().BeTrue(); raised.Should().Be(1); sut.CanFocus = false; sut.CanFocus.Should().BeFalse(); raised.Should().Be(2); sut.CanFocus = false; sut.CanFocus.Should().BeFalse(); raised.Should().Be(2); sut.CanFocus = true; sut.CanFocus.Should().BeTrue(); raised.Should().Be(3); }
public void CanFocus_Get_True() { using var stubbedWindow = new StubbedWindow(); var textController = new StubbedConsoleTextController(); using var sut = new ConControls.Controls.Button(stubbedWindow, textController); sut.CanFocus.Should().BeTrue(); }
public void TabStop_InitiallyTrue() { using var stubbedWindow = new StubbedWindow(); using var sut = new ConControls.Controls.Button(stubbedWindow); sut.TabStop.Should().BeTrue(); sut.TabStop = false; sut.TabStop.Should().BeFalse(); sut.TabStop = true; sut.TabStop.Should().BeTrue(); }
public void CursorVisible_AlwaysFalse() { using var stubbedWindow = new StubbedWindow(); using var sut = new ConControls.Controls.Button(stubbedWindow); sut.CursorVisible.Should().BeFalse(); sut.CursorVisible = true; sut.CursorVisible.Should().BeFalse(); sut.CursorVisible = false; sut.CursorVisible.Should().BeFalse(); }
public void PerformClick_Invisible_Nothing() { using var stubbedWindow = new StubbedWindow(); using var sut = new ConControls.Controls.Button(stubbedWindow) { Parent = stubbedWindow, Visible = false }; bool clicked = false; sut.Click += (sender, e) => clicked = true; sut.PerformClick(); clicked.Should().BeFalse(); }
public void Text_EnclosedInParanthesis() { using var stubbedWindow = new StubbedWindow(); string text = string.Empty; var stubbedController = new StubbedConsoleTextController { TextGet = () => text, TextSetString = s => text = s }; using var sut = new ConControls.Controls.Button(stubbedWindow, stubbedController) { Text = "Hello World!" }; sut.Text.Should().Be("Hello World!"); text.Should().Be("[Hello World!]"); }
public void PerformClick_EventRaised() { using var stubbedWindow = new StubbedWindow(); using var sut = new ConControls.Controls.Button(stubbedWindow) { Parent = stubbedWindow }; bool clicked = false; sut.Click += OnClick; sut.PerformClick(); clicked.Should().BeTrue(); clicked = false; sut.Click -= OnClick; sut.PerformClick(); clicked = false; void OnClick(object sender, EventArgs e) { sender.Should().Be(sut); clicked = true; } }
public void Text_Empty_Empty() { using var stubbedWindow = new StubbedWindow(); using var sut = new ConControls.Controls.Button(stubbedWindow); sut.Text.Should().BeEmpty(); }