Example #1
0
        public void IntellisenseTextBoxTests_ValidateText_FilterTypeIsJsonObjectAndTextIsScalar_ToolTipHasNoErrorMessage()
        {
            var mockPresentationSource = new Mock <PresentationSource>();
            var testHelper             = new IntellisenseTextBoxTestHelper();

            testHelper.OnKeyDown(new KeyEventArgs(null, mockPresentationSource.Object, 0, Key.Escape));
            Assert.IsFalse(testHelper.IsDropDownOpen);
        }
Example #2
0
        public void IntellisenseBox_GivenMultipleValidVariables_HasNoError()
        {
            var textBoxTest = new IntellisenseTextBoxTestHelper {
                AllowMultipleVariables = true
            };

            textBoxTest.Text = "\"[[Var]]\", \"[[Var()]]\"";
            textBoxTest.EnsureErrorStatus();
            Assert.IsFalse(textBoxTest.HasError);
            Assert.AreEqual(textBoxTest.DefaultText, textBoxTest.ToolTip);
        }
Example #3
0
        public void IntellisenseBox_GivenWrappedInBrackets_AStringWithNoBrackets_Should_AddBrackets()
        {
            var textBoxTest = new IntellisenseTextBoxTestHelper {
                WrapInBrackets = true
            };

            textBoxTest.Text = "Variable";
            textBoxTest.HandleWrapInBrackets(Key.F6);
            Assert.IsFalse(textBoxTest.HasError);
            Assert.AreEqual("[[Variable]]", textBoxTest.Text);
        }
Example #4
0
        public void IntellisenseBox_Function_HasIsCalcMode_SetTo_True()
        {
            var textBoxTest = new IntellisenseTextBoxTestHelper {
                AllowUserCalculateMode = true
            };

            textBoxTest.EnsureIntellisenseResults(null, false, IntellisenseDesiredResultSet.Default);
            Assert.IsTrue(string.IsNullOrEmpty(textBoxTest.Text));
            var input = textBoxTest.Text = "=Sum(5,5)";

            textBoxTest.EnsureIntellisenseResults(input, false, IntellisenseDesiredResultSet.Default);
            Assert.IsTrue(textBoxTest.IsInCalculateMode);
        }
Example #5
0
        public void IntellisenseBox_OnPreviewKeyDown_GivenI_Hit_Enter_Key_And_AlloInsertLine_Is_True_Should_AddLine()
        {
            var mockPresentationSource = new Mock <PresentationSource>();
            var textBox = new Mock <TextBox>();

            textBox.Object.MinLines = 5;
            textBox.Object.Text     = "Var";
            var testHelper = new IntellisenseTextBoxTestHelper
            {
                AllowUserInsertLine = true,
                TextBox             = textBox.Object,
                MinLines            = textBox.Object.MinLines
            };

            testHelper.OnPreviewKeyDown(new KeyEventArgs(Keyboard.PrimaryDevice, mockPresentationSource.Object, 0, Key.Enter));
            Assert.IsFalse(testHelper.HasError);
        }
Example #6
0
        public void IntellisenseBox_OnPreviewKeyDown_GivenI_Hit_Tab_Key_Should_AppendText()
        {
            var mockPresentationSource = new Mock <PresentationSource>();
            var textBox = new Mock <TextBox>();

            textBox.Object.MinLines = 5;
            var givenText = textBox.Object.Text = "Var";

            Assert.IsFalse(givenText.Contains("\r\n"));
            var testHelper = new IntellisenseTextBoxTestHelper
            {
                AllowUserInsertLine = true,
                TextBox             = textBox.Object,
                IsDropDownOpen      = true,
            };

            testHelper.OnPreviewKeyDown(new KeyEventArgs(Keyboard.PrimaryDevice, mockPresentationSource.Object, 0, Key.Tab));
            Assert.IsFalse(testHelper.HasError);
            Assert.IsFalse(testHelper.TextBox.Text.Contains("\r\n"));
        }
Example #7
0
        public void IntellisenseBox_OnPreviewKeyDown_Given_EnterKey_And_AllowInsertLineIsTrueButLineCountIsEqualToMaximumLine_ShouldNotAddLine()
        {
            var mockPresentationSource = new Mock <PresentationSource>();
            var textBox = new Mock <TextBox>();

            textBox.Object.MinLines = 5;
            var givenText = textBox.Object.Text = "Var";

            Assert.IsFalse(givenText.Contains("\r\n"));
            var testHelper = new IntellisenseTextBoxTestHelper
            {
                AllowUserInsertLine = true,
                TextBox             = textBox.Object,
                MinLines            = textBox.Object.MinLines,
                LineCount           = 5
            };

            testHelper.OnPreviewKeyDown(new KeyEventArgs(Keyboard.PrimaryDevice, mockPresentationSource.Object, 0, Key.Enter));
            Assert.IsFalse(testHelper.HasError);
            Assert.IsFalse(testHelper.TextBox.Text.Contains("\r\n"));
        }