<commit_before>namespace Gu.Wpf.PropertyGrid.UiTests
{
    using NUnit.Framework;

    using TestStack.White;
    using TestStack.White.UIItems;
    using TestStack.White.UIItems.WindowItems;
    using TestStack.White.WindowsAPI;

    public class NestedTests
    {
        private Application application;
        private Window window;

        [OneTimeSetUp]
        public void OneTimeSetUp()
        {
            var title = "NestedWindow";
            this.application = Application.AttachOrLaunch(Info.CreateStartInfo(title));
            this.window = this.application.GetWindow(title);
        }

        [OneTimeTearDown]
        public void OneTimeTearDown()
        {
            this.application?.Dispose();
        }

        [Test]
        public void CyclesFocus()
        {
            var groupBox = this.window.GetByText<GroupBox>("nested longer");
            var rootBox = groupBox.FindRow("root").Value<TextBox>();
            var shortBox = groupBox.FindRow("a").Value<TextBox>();
            var longBox = groupBox.FindRow("long header").Value<TextBox>();
            rootBox.Focus();
            Assert.True(rootBox.IsFocussed);
            Assert.False(shortBox.IsFocussed);
            Assert.False(longBox.IsFocussed);

            this.window.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.TAB);
            Assert.False(rootBox.IsFocussed);
            Assert.True(shortBox.IsFocussed);
            Assert.False(longBox.IsFocussed);

            this.window.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.TAB);
            Assert.False(rootBox.IsFocussed);
            Assert.False(shortBox.IsFocussed);
            Assert.True(longBox.IsFocussed);

            this.window.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.TAB);
            Assert.True(rootBox.IsFocussed);
            Assert.False(shortBox.IsFocussed);
            Assert.False(longBox.IsFocussed);
        }

        [Test]
        public void ColumnWidthsWhenNestedLonger()
        {
            var groupBox = this.window.GetByText<GroupBox>("nested longer");
            var expected = new[] { 64, 92, 86 };
            CollectionAssert.AreEqual(expected, groupBox.FindRow("root").ColumnsWidths<TextBox>());
            CollectionAssert.AreEqual(expected, groupBox.FindRow("a").ColumnsWidths<TextBox>());
            CollectionAssert.AreEqual(expected, groupBox.FindRow("long header").ColumnsWidths<TextBox>());
        }

        [Test]
        public void ColumnWidthsWhenNestedShorter()
        {
            var groupBox = this.window.GetByText<GroupBox>("nested shorter");
            var expected = new[] { 22, 34, 57 };
            CollectionAssert.AreEqual(expected, groupBox.FindRow("root").ColumnsWidths<TextBox>());
            expected[2] = 28;
            CollectionAssert.AreEqual(expected, groupBox.FindRow("a").ColumnsWidths<TextBox>());
            CollectionAssert.AreEqual(expected, groupBox.FindRow("b").ColumnsWidths<TextBox>());
        }
    }
}<commit_msg>Refactor NestedTests<commit_after>namespace Gu.Wpf.PropertyGrid.UiTests
{
    using Gu.Wpf.UiAutomation;
    using NUnit.Framework;

    public class NestedTests
    {
        private static readonly string WindowName = "NestedWindow";

        [OneTimeTearDown]
        public void OneTimeTearDown()
        {
            Application.KillLaunched(Info.ExeFileName);
        }

        [Test]
        public void CyclesFocus()
        {
            using (var app = Application.AttachOrLaunch(Info.ExeFileName, WindowName))
            {
                var window = app.MainWindow;
                var groupBox = window.FindGroupBox("nested longer");
                var rootBox = groupBox.FindTextBoxRow("root").Value();
                var shortBox = groupBox.FindTextBoxRow("a").Value();
                var longBox = groupBox.FindTextBoxRow("long header").Value();
                rootBox.Focus();
                Assert.True(rootBox.HasKeyboardFocus);
                Assert.False(shortBox.HasKeyboardFocus);
                Assert.False(longBox.HasKeyboardFocus);

                Keyboard.Type(Key.TAB);
                Assert.False(rootBox.HasKeyboardFocus);
                Assert.True(shortBox.HasKeyboardFocus);
                Assert.False(longBox.HasKeyboardFocus);

                Keyboard.Type(Key.TAB);
                Assert.False(rootBox.HasKeyboardFocus);
                Assert.False(shortBox.HasKeyboardFocus);
                Assert.True(longBox.HasKeyboardFocus);

                Keyboard.Type(Key.TAB);
                Assert.True(rootBox.HasKeyboardFocus);
                Assert.False(shortBox.HasKeyboardFocus);
                Assert.False(longBox.HasKeyboardFocus);
            }
        }

        [Test]
        public void ColumnWidthsWhenNestedLonger()
        {
            using (var app = Application.AttachOrLaunch(Info.ExeFileName, WindowName))
            {
                var window = app.MainWindow;
                var groupBox = window.FindGroupBox("nested longer");
                var expected = new[] {64, 92, 86};
                CollectionAssert.AreEqual(expected, groupBox.FindTextBoxRow("root").ColumnsWidths());
                CollectionAssert.AreEqual(expected, groupBox.FindTextBoxRow("a").ColumnsWidths());
                CollectionAssert.AreEqual(expected, groupBox.FindTextBoxRow("long header").ColumnsWidths());
            }
        }

        [Test]
        public void ColumnWidthsWhenNestedShorter()
        {
            using (var app = Application.AttachOrLaunch(Info.ExeFileName, WindowName))
            {
                var window = app.MainWindow;
                var groupBox = window.FindGroupBox("nested shorter");
                var expected = new[] {22, 34, 57};
                CollectionAssert.AreEqual(expected, groupBox.FindTextBoxRow("root").ColumnsWidths());
                expected[2] = 28;
                CollectionAssert.AreEqual(expected, groupBox.FindTextBoxRow("a").ColumnsWidths());
                CollectionAssert.AreEqual(expected, groupBox.FindTextBoxRow("b").ColumnsWidths());
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.10832513929859063, 'fraction_numerical': 0.004916420845624385, 'mean_word_length': 2.1621761658031087, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '357464', 'n_tokens_mistral': 1674, 'n_tokens_neox': 1596, 'n_words': 236}