Esempio n. 1
0
        public void CanValidateTextWithEvent_InitiallyBlank()
        {
            var paragraph = Browser.FindElement(By.Id("validate-text-with-event-initially-blank"));
            var edit      = paragraph.FindElement(By.TagName("input"));

            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys("a");
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys(Keys.Backspace);
            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));
        }
Esempio n. 2
0
        public void CanUseJsInteropToReferenceElements()
        {
            var appElement    = MountTestComponent <ElementRefComponent>();
            var inputElement  = appElement.FindElement(By.Id("capturedElement"));
            var buttonElement = appElement.FindElement(By.TagName("button"));

            Assert.Equal(string.Empty, inputElement.GetAttribute("value"));

            buttonElement.Click();
            WaitAssert.Equal("Clicks: 1", () => inputElement.GetAttribute("value"));
            buttonElement.Click();
            WaitAssert.Equal("Clicks: 2", () => inputElement.GetAttribute("value"));
        }
        public void CanValidateNumericWithBind_InitiallyBlank()
        {
            var paragraph = Browser.FindElement(By.Id("validate-numeric-with-bind-initially-blank"));
            var edit      = paragraph.FindElement(By.TagName("input"));

            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys("1");
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys(Keys.Backspace);
            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));
        }
Esempio n. 4
0
        public void CanValidateTextWithBind_InitiallyPopulated()
        {
            var paragraph = Browser.FindElement(By.Id("validate-text-with-bind-initially-populated"));
            var edit      = paragraph.FindElement(By.TagName("input"));

            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys(Keys.Backspace);
            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys("b");
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));
        }
Esempio n. 5
0
        public void CanValidateStringWithEvent_InitiallySelected()
        {
            var paragraph = Browser.FindElement(By.Id("validate-string-with-event-initially-selected"));
            var select    = new SelectElement(paragraph.FindElement(By.TagName("select")));

            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            select.SelectByIndex(1);
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            select.SelectByIndex(0);
            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));
        }
Esempio n. 6
0
        public void CanBindTextArea_InitiallyPopulated()
        {
            var target     = Browser.FindElement(By.Id("textarea-initially-populated"));
            var boundValue = Browser.FindElement(By.Id("textarea-initially-populated-value"));

            Assert.Equal("Hello", target.GetAttribute("value"));
            Assert.Equal("Hello", boundValue.Text);

            // Modify target; verify value is updated
            target.Clear();
            target.SendKeys("Changed value\t");
            WaitAssert.Equal("Changed value", () => boundValue.Text);
        }
Esempio n. 7
0
        public void CanValidateEnumWithBind_InitiallyBlank()
        {
            var paragraph = Browser.FindElement(By.Id("validate-enum-with-bind-initially-blank"));
            var select    = new SelectElement(paragraph.FindElement(By.TagName("select")));

            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            select.SelectByIndex(1);
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            select.SelectByIndex(0);
            WaitAssert.True(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));
        }
        public void TestConcurrentCreateNCreateIndexDB()
        {
            const int nDocs = 1000;

            var exp1   = new WaitAssert();
            var ignore = exp1.RunAssertAsync(() =>
            {
                CreateDocs(nDocs, "Create").ToList();
            });

            Db.CreateIndex("sentence", IndexBuilder.FullTextIndex(FullTextIndexItem.Property("sentence")));
            exp1.WaitForResult(TimeSpan.FromSeconds(60));
        }
        public void TestConcurrentCreateNCompactDB()
        {
            const int nDocs = 1000;

            var exp1   = new WaitAssert();
            var ignore = exp1.RunAssertAsync(() =>
            {
                CreateDocs(nDocs, "Create").ToList();
            });

            Db.PerformMaintenance(MaintenanceType.Compact);
            exp1.WaitForResult(TimeSpan.FromSeconds(60));
        }
Esempio n. 10
0
        public void CannotChangeElementId()
        {
            var appElement = MountTestComponent <ElementIdComponent>();
            var date       = appElement.FindElement(By.TagName("input"));
            var button     = appElement.FindElement(By.TagName("button"));

            Assert.NotEqual(string.Empty, date.GetAttribute("id"));

            var before = date.GetAttribute("id");

            button.Click();
            WaitAssert.Equal(before, () => date.GetAttribute("id"));
        }
        public void TestStopContinuousReplicator()
        {
            var config = CreateConfig(true, false, true);

            using (var r = new Replicator(config)) {
                var stopWhen = new[]
                {
                    ReplicatorActivityLevel.Connecting, ReplicatorActivityLevel.Busy,
                    ReplicatorActivityLevel.Idle, ReplicatorActivityLevel.Idle
                };

                foreach (var when in stopWhen)
                {
                    var stopped    = 0;
                    var waitAssert = new WaitAssert();
                    var token      = r.AddChangeListener((sender, args) =>
                    {
                        waitAssert.RunConditionalAssert(() =>
                        {
                            VerifyChange(args, 0, 0);

                            // On Windows, at least, sometimes the connection is so fast that Connecting never gets called
                            if ((args.Status.Activity == when ||
                                 (when == ReplicatorActivityLevel.Connecting && args.Status.Activity > when)) &&
                                Interlocked.Exchange(ref stopped, 1) == 0)
                            {
                                WriteLine("***** Stop Replicator *****");
                                ((Replicator)sender).Stop();
                            }

                            if (args.Status.Activity == ReplicatorActivityLevel.Stopped)
                            {
                                WriteLine("Stopped!");
                            }

                            return(args.Status.Activity == ReplicatorActivityLevel.Stopped);
                        });
                    });

                    WriteLine("***** Start Replicator *****");
                    r.Start();
                    try {
                        waitAssert.WaitForResult(TimeSpan.FromSeconds(5));
                    } finally {
                        r.RemoveChangeListener(token);
                    }

                    Task.Delay(100).Wait();
                }
            }
        }
        public void TestConcurrentCreateAndDeleteDB()
        {
            const int nDocs = 1000;

            var exp1   = new WaitAssert();
            var ignore = exp1.RunAssertAsync(() =>
            {
                Action a = () => CreateDocs(nDocs, "Create").ToList();
                a.Should().Throw <InvalidOperationException>();
            });

            Db.Delete();
            exp1.WaitForResult(TimeSpan.FromSeconds(60));
        }
Esempio n. 13
0
        public void CanChangeUndefinedDecimalUsingEvent()
        {
            var paragraph = Browser.FindElement(By.Id("decimal-event-initially-undefined"));
            var numeric   = paragraph.FindElement(By.TagName("input"));
            var result    = paragraph.FindElement(By.Id("decimal-event-initially-undefined-result"));

            WaitAssert.Equal("0", () => result.Text);

            numeric.SendKeysSequentially("100");
            WaitAssert.Equal("100", () => result.Text);

            numeric.SendKeys(Keys.Backspace);
            WaitAssert.Equal("10", () => result.Text);
        }
Esempio n. 14
0
        public void CanBindTextArea_InitiallyBlank()
        {
            var target     = Browser.FindElement(By.Id("textarea-initially-blank"));
            var boundValue = Browser.FindElement(By.Id("textarea-initially-blank-value"));

            Assert.Equal(string.Empty, target.GetAttribute("value"));
            Assert.Equal(string.Empty, boundValue.Text);

            // Modify target; verify value is updated
            target.SendKeys("Changed value");
            Assert.Equal(string.Empty, boundValue.Text); // Don't update as there's no change event fired yet.
            target.SendKeys("\t");
            WaitAssert.Equal("Changed value", () => boundValue.Text);
        }
Esempio n. 15
0
        public void CanChangeTextUsingEvent()
        {
            var paragraph = Browser.FindElement(By.Id("text-event-initially-blank"));
            var text      = paragraph.FindElement(By.TagName("input"));
            var result    = paragraph.FindElement(By.Id("text-event-initially-blank-result"));

            WaitAssert.Equal(string.Empty, () => result.Text);

            text.SendKeysSequentially("abcdefghijklmnopqrstuvwxyz");
            WaitAssert.Equal("abcdefghijklmnopqrstuvwxyz", () => result.Text);

            text.SendKeys(Keys.Backspace);
            WaitAssert.Equal("abcdefghijklmnopqrstuvwxy", () => result.Text);
        }
Esempio n. 16
0
        public void CanBindText()
        {
            var appElement = MountTestComponent <TextEditComponent>();
            var txtElement = appElement.FindElement(By.TagName("input"));
            var output     = Browser.FindElement(By.Id("test-result"));

            WaitAssert.Equal(string.Empty, () => output.Text);

            txtElement.SendKeysSequentially("abcdefghijklmnopqrstuvwxyz");
            WaitAssert.Equal("abcdefghijklmnopqrstuvwxyz", () => output.Text);

            txtElement.SendKeys(Keys.Backspace);
            WaitAssert.Equal("abcdefghijklmnopqrstuvwxy", () => output.Text);
        }
Esempio n. 17
0
        public void CanValidateText_InitiallyPopulated()
        {
            var paragraph = Browser.FindElement(By.Id("validate-text-initially-populated"));
            var edit      = paragraph.FindElement(By.TagName("input"));

            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            // although input should be cleared it will be reset to the default value
            edit.SendKeys(Keys.Backspace);
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));

            edit.SendKeys("b");
            WaitAssert.False(() => paragraph.ElementIsPresent(By.ClassName("invalid-feedback")));
        }
Esempio n. 18
0
        public void CanRaiseCallback()
        {
            var paragraph = Browser.FindElement(By.Id("close-button-event"));
            var button    = paragraph.FindElement(By.TagName("button"));
            var result    = paragraph.FindElement(By.Id("close-button-event-result"));

            WaitAssert.Equal("0", () => result.Text);

            button.Click();
            WaitAssert.Equal("1", () => result.Text);

            button.Click();
            WaitAssert.Equal("2", () => result.Text);
        }
Esempio n. 19
0
        public void CanChangeNullableDecimalUsingEvent()
        {
            var paragraph = Browser.FindElement(By.Id("nullable-decimal-event-initially-null"));
            var numeric   = paragraph.FindElement(By.TagName("input"));
            var result    = paragraph.FindElement(By.Id("nullable-decimal-event-initially-null-result"));

            WaitAssert.Equal(string.Empty, () => result.Text);

            numeric.SendKeysSequentially("100");
            WaitAssert.Equal("100", () => result.Text);

            numeric.SendKeys(Keys.Backspace);
            WaitAssert.Equal("10", () => result.Text);
        }
Esempio n. 20
0
        public void ChildComponentsRerenderWhenPropertiesChanged()
        {
            // Count value is displayed in child component with initial value zero
            var appElement            = MountTestComponent <CounterComponentUsingChild>();
            var wholeCounterElement   = appElement.FindElement(By.TagName("p"));
            var messageElementInChild = wholeCounterElement.FindElement(By.ClassName("message"));

            Assert.Equal("Current count: 0", wholeCounterElement.Text);
            Assert.Equal("0", messageElementInChild.Text);

            // Clicking increments count in child element
            appElement.FindElement(By.TagName("button")).Click();
            WaitAssert.Equal("1", () => messageElementInChild.Text);
        }
Esempio n. 21
0
        public void CanNavigateProgrammatically()
        {
            SetUrlViaPushState("/");

            var app          = MountTestComponent <TestRouter>();
            var testSelector = WaitUntilTestSelectorReady();

            app.FindElement(By.Id("do-navigation")).Click();
            WaitAssert.True(() => Browser.Url.EndsWith("/Other"));
            WaitAssert.Equal("This is another page.", () => app.FindElement(By.Id("test-info")).Text);
            AssertHighlightedLinks("Other", "Other with base-relative URL (matches all)");

            // Because this was client-side navigation, we didn't lose the state in the test selector
            Assert.Equal(typeof(TestRouter).FullName, testSelector.SelectedOption.GetAttribute("value"));
        }
        public void TestConcurrentCreateNCompactDB()
        {
            const int nDocs = 1000;

            var tag1 = "Create";
            var exp1 = new WaitAssert();

            exp1.RunAssertAsync(() =>
            {
                CreateDocs(nDocs, "Create").ToList();
            });

            Db.Compact();
            exp1.WaitForResult(TimeSpan.FromSeconds(60));
        }
Esempio n. 23
0
        public void CanChangeValueWithStepDefault()
        {
            var paragraph = Browser.FindElement(By.Id("step-change-default"));
            var numeric   = paragraph.FindElement(By.TagName("input"));
            var result    = paragraph.FindElement(By.Id("step-change-default-result"));

            WaitAssert.Equal("1", () => result.Text);

            numeric.SendKeys(Keys.Up);
            numeric.SendKeys(Keys.Up);
            WaitAssert.Equal("3", () => result.Text);

            numeric.SendKeys(Keys.Down);
            WaitAssert.Equal("2", () => result.Text);
        }
        private void ConcurrentRuns(uint nRuns, Action <uint> block)
        {
            var expectations = new WaitAssert[nRuns];

            for (uint i = 0; i < nRuns; i++)
            {
                expectations[i] = new WaitAssert();
                var ignore = expectations[i].RunAssertAsync(block, i);
            }

            foreach (var exp in expectations)
            {
                exp.WaitForResult(TimeSpan.FromSeconds(60));
            }
        }
Esempio n. 25
0
        public void CanShowAndHideDropdownComponent()
        {
            var appElement = MountTestComponent <DropdownComponent>();
            var drpElement = appElement.FindElement(By.ClassName("dropdown"));
            var btnElement = drpElement.FindElement(By.TagName("button"));
            var mnuElement = drpElement.FindElement(By.ClassName("dropdown-menu"));

            btnElement.Click();
            WaitAssert.Contains("show", () => drpElement.GetAttribute("class"));
            WaitAssert.Contains("show", () => mnuElement.GetAttribute("class"));

            btnElement.Click();
            WaitAssert.NotContains("show", () => drpElement.GetAttribute("class"));
            WaitAssert.NotContains("show", () => mnuElement.GetAttribute("class"));
        }
Esempio n. 26
0
        public void InputEvent_RespondsOnKeystrokes()
        {
            MountTestComponent <InputEventComponent>();

            var input  = Browser.FindElement(By.TagName("input"));
            var output = Browser.FindElement(By.Id("test-result"));

            WaitAssert.Equal(string.Empty, () => output.Text);

            SendKeysSequentially(input, "abcdefghijklmnopqrstuvwxyz");
            WaitAssert.Equal("abcdefghijklmnopqrstuvwxyz", () => output.Text);

            input.SendKeys(Keys.Backspace);
            WaitAssert.Equal("abcdefghijklmnopqrstuvwxy", () => output.Text);
        }
Esempio n. 27
0
        public void CanTriggerAsyncEventHandlers()
        {
            // Initial state is stopped
            var appElement   = MountTestComponent <AsyncEventHandlerComponent>();
            var stateElement = appElement.FindElement(By.Id("state"));

            Assert.Equal("Stopped", stateElement.Text);

            // Clicking 'tick' changes the state, and starts a task
            appElement.FindElement(By.Id("tick")).Click();
            WaitAssert.Equal("Started", () => stateElement.Text);

            // Clicking 'tock' completes the task, which updates the state
            appElement.FindElement(By.Id("tock")).Click();
            WaitAssert.Equal("Stopped", () => stateElement.Text);
        }
Esempio n. 28
0
        public void ChildComponentsNotifiedWhenPropertiesChanged()
        {
            // Child component receives notification that lets it compute a property before first render
            var appElement           = MountTestComponent <PropertiesChangedHandlerParent>();
            var suppliedValueElement = appElement.FindElement(By.ClassName("supplied"));
            var computedValueElement = appElement.FindElement(By.ClassName("computed"));
            var incrementButton      = appElement.FindElement(By.TagName("button"));

            Assert.Equal("You supplied: 100", suppliedValueElement.Text);
            Assert.Equal("I computed: 200", computedValueElement.Text);

            // When property changes, child is renotified before rerender
            incrementButton.Click();
            WaitAssert.Equal("You supplied: 101", () => suppliedValueElement.Text);
            Assert.Equal("I computed: 202", computedValueElement.Text);
        }
Esempio n. 29
0
        public void CanRenderSvgWithCorrectNamespace()
        {
            var appElement = MountTestComponent <SvgComponent>();

            var svgElement = appElement.FindElement(By.XPath("//*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']"));

            Assert.NotNull(svgElement);

            var svgCircleElement = appElement.FindElement(By.XPath("//*[local-name()='circle' and namespace-uri()='http://www.w3.org/2000/svg']"));

            Assert.NotNull(svgCircleElement);
            Assert.Equal("10", svgCircleElement.GetAttribute("r"));

            appElement.FindElement(By.TagName("button")).Click();
            WaitAssert.Equal("20", () => svgCircleElement.GetAttribute("r"));
        }
Esempio n. 30
0
        public void CanNavigateProgrammaticallyWithForceLoad()
        {
            SetUrlViaPushState("/");

            var app          = MountTestComponent <TestRouter>();
            var testSelector = WaitUntilTestSelectorReady();

            app.FindElement(By.Id("do-navigation-forced")).Click();
            WaitAssert.True(() => Browser.Url.EndsWith("/Other"));

            // Because this was a full-page load, our element references should no longer be valid
            Assert.Throws <StaleElementReferenceException>(() =>
            {
                testSelector.SelectedOption.GetAttribute("value");
            });
        }