예제 #1
0
        public virtual void ShouldNotReactToInvalidText()
        {
            OverriddenDomainUpDown dud = new OverriddenDomainUpDown();

            dud.Items.Add("a");
            dud.Items.Add("b");
            dud.Items.Add("c");

            TestAsync(
                dud,
                () => dud.ApplyText("b"),
                () => dud.ApplyText("d"),
                () => Assert.AreEqual(1, dud.CurrentIndex));
        }
예제 #2
0
        public virtual void ShouldHandleInvalidTextCorrectly()
        {
            OverriddenDomainUpDown dud = new OverriddenDomainUpDown();

            dud.Items.Add("a");
            dud.Items.Add("b");
            dud.Items.Add("c");
            dud.Items.Add("fallback");

            dud.InvalidInputAction = InvalidInputAction.UseFallbackItem;
            dud.FallbackItem       = "fallback";

            TestAsync(
                dud,
                () => dud.CurrentIndex = 1,
                () => dud.ApplyText("does not exist"),
                () => Assert.AreEqual("fallback", dud.Value),
                () => dud.FallbackItem = "fallback does not exist",
                () => dud.CurrentIndex = 1,
                () => dud.ApplyText("does not exist"),
                () => Assert.AreEqual("b", dud.Value));
        }
예제 #3
0
        public virtual void ShouldSelectItemWhenTextChanges()
        {
            OverriddenDomainUpDown dud = new OverriddenDomainUpDown();

            dud.Items.Add("a");
            dud.Items.Add("b");
            dud.Items.Add("c");

            TestAsync(
                dud,
                () => dud.ApplyText("b"),
                () => Assert.AreEqual(1, dud.CurrentIndex));
        }
예제 #4
0
        public virtual void ShouldUseValueMemberPath()
        {
            OverriddenDomainUpDown dud = new OverriddenDomainUpDown();

            dud.ValueMemberPath = "Value";
            dud.ItemsSource     = new[]
            {
                new KeyValuePair <string, string>("a", "b"),
                new KeyValuePair <string, string>("c", "d"),
            };

            TestAsync(
                dud,
                () => dud.ApplyText("d"),
                () => Assert.AreEqual(1, dud.CurrentIndex));
        }
예제 #5
0
        public virtual void ShouldRemainInEditModeAfterInvalidInputAndTextBoxCannotLoseFocusAction()
        {
            OverriddenDomainUpDown dud = new OverriddenDomainUpDown();

            dud.Items.Add("a");
            dud.Items.Add("b");
            dud.Items.Add("c");
            dud.Items.Add("fallback");

            dud.InvalidInputAction = InvalidInputAction.TextBoxCannotLoseFocus;
            dud.FallbackItem       = "fallback";

            dud.CurrentIndex = 1;
            dud.ApplyText("does not exist");
            Assert.AreEqual(true, dud.IsEditing);
        }
예제 #6
0
        public virtual void ShouldReturnToDisplayAfterInvalidValue()
        {
            OverriddenDomainUpDown dud = new OverriddenDomainUpDown();

            dud.Items.Add("a");
            dud.Items.Add("b");
            dud.Items.Add("c");
            dud.Items.Add("fallback");

            dud.InvalidInputAction = InvalidInputAction.UseFallbackItem;
            dud.FallbackItem       = "fallback";

            dud.CurrentIndex = 1;
            dud.ApplyText("does not exist");
            Assert.AreEqual(false, dud.IsEditing);
        }