public void LabelPositionLeftWithInnerTop()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;

                dataFormApp.dataForm.CurrentItem = new DataClass();
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                Label fieldLabel1 = this.DataFormLabels[0] as Label;
                CheckBox checkBox = this.DataFormInputControls[0] as CheckBox;

                Assert.IsTrue(this.GetPosition(fieldLabel1).X < this.GetPosition(checkBox).X);

                Label fieldLabel2     = this.DataFormLabels[1] as Label;
                DatePicker datePicker = this.DataFormInputControls[1] as DatePicker;

                Assert.IsTrue(this.GetPosition(fieldLabel2).X < this.GetPosition(datePicker).X);

                Label fieldLabel3 = this.DataFormLabels[2] as Label;
                TextBox textBox   = this.DataFormInputControls[2] as TextBox;

                Assert.IsTrue(this.GetPosition(fieldLabel3).X < this.GetPosition(textBox).X);

                Label fieldLabel4   = this.DataFormLabels[3] as Label;
                TextBlock textBlock = this.DataFormInputControls[3] as TextBlock;

                Assert.IsTrue(this.GetPosition(fieldLabel4).Y < this.GetPosition(textBlock).Y);

                Label fieldLabel5 = this.DataFormLabels[4] as Label;
                ComboBox comboBox = this.DataFormInputControls[4] as ComboBox;

                Assert.IsTrue(this.GetPosition(fieldLabel5).X < this.GetPosition(comboBox).X);

                Label fieldLabel6     = this.DataFormLabels[5] as Label;
                TextBox innerTextBox1 = this.DataFormInputControls[5] as TextBox;

                Assert.IsTrue(this.GetPosition(fieldLabel6).X < this.GetPosition(innerTextBox1).X);

                Label fieldLabel7     = this.DataFormLabels[6] as Label;
                TextBox innerTextBox2 = this.DataFormInputControls[6] as TextBox;

                Assert.IsTrue(this.GetPosition(fieldLabel7).X < this.GetPosition(innerTextBox2).X);
            });

            this.EnqueueTestComplete();
        }
        public void ChangeDescriptionViewerPositionOnDataForm()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();

            dataFormApp.dataForm.CurrentItem = new DataClass();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                foreach (DataField field in dataFormApp.dataForm.Fields)
                {
                    DescriptionViewer descriptionViewer = this.DataFormDescriptions[0];
                    Label fieldLabel = this.DataFormLabels[0];
                    FrameworkElement inputControl = this.DataFormInputControls[0];

                    Assert.IsTrue(this.GetPosition(fieldLabel).X < this.GetPosition(inputControl).X);
                    Assert.IsTrue(this.GetPosition(inputControl).X < this.GetPosition(descriptionViewer).X);
                }

                dataFormApp.dataForm.DescriptionViewerPosition = DataFieldDescriptionViewerPosition.BesideLabel;
            });

            // Give the DataFields time to update their UI.
            this.EnqueueDelay(100);

            this.EnqueueCallback(() =>
            {
                foreach (DataField field in dataFormApp.dataForm.Fields)
                {
                    DescriptionViewer descriptionViewer = this.DataFormDescriptions[0];
                    Label fieldLabel = this.DataFormLabels[0];
                    FrameworkElement inputControl = this.DataFormInputControls[0];

                    Assert.IsTrue(this.GetPosition(fieldLabel).X < this.GetPosition(descriptionViewer).X);
                    Assert.IsTrue(this.GetPosition(descriptionViewer).X < this.GetPosition(inputControl).X);
                }
            });

            this.EnqueueTestComplete();
        }
        public void ChangeDescriptionViewerPositionOnDataForm()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.CurrentItem = new DataClass();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                foreach (DataField field in dataFormApp.dataForm.Fields)
                {
                    DescriptionViewer descriptionViewer = this.DataFormDescriptions[0];
                    Label fieldLabel = this.DataFormLabels[0];
                    FrameworkElement inputControl = this.DataFormInputControls[0];

                    Assert.IsTrue(this.GetPosition(fieldLabel).X < this.GetPosition(inputControl).X);
                    Assert.IsTrue(this.GetPosition(inputControl).X < this.GetPosition(descriptionViewer).X);
                }

                dataFormApp.dataForm.DescriptionViewerPosition = DataFieldDescriptionViewerPosition.BesideLabel;
            });

            // Give the DataFields time to update their UI.
            this.EnqueueDelay(100);

            this.EnqueueCallback(() =>
            {
                foreach (DataField field in dataFormApp.dataForm.Fields)
                {
                    DescriptionViewer descriptionViewer = this.DataFormDescriptions[0];
                    Label fieldLabel = this.DataFormLabels[0];
                    FrameworkElement inputControl = this.DataFormInputControls[0];

                    Assert.IsTrue(this.GetPosition(fieldLabel).X < this.GetPosition(descriptionViewer).X);
                    Assert.IsTrue(this.GetPosition(descriptionViewer).X < this.GetPosition(inputControl).X);
                }
            });

            this.EnqueueTestComplete();
        }
        public void EnsureLabelAlignmentIsCorrect()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;

                dataFormApp.dataForm.CurrentItem = new DataClass();
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                Label fieldLabel1 = this.DataFormLabels[0] as Label;
                Label fieldLabel2 = this.DataFormLabels[1] as Label;
                Label fieldLabel3 = this.DataFormLabels[2] as Label;

                Assert.IsTrue(this.GetPosition(fieldLabel1).X + fieldLabel1.ActualWidth == this.GetPosition(fieldLabel2).X + fieldLabel2.ActualWidth);
                Assert.IsTrue(this.GetPosition(fieldLabel2).X + fieldLabel2.ActualWidth == this.GetPosition(fieldLabel3).X + fieldLabel3.ActualWidth);

                Style innerStyle = new Style(typeof(Label));
                innerStyle.Setters.Add(new Setter(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Left));
                Style style = new Style(typeof(DataField));
                style.Setters.Add(new Setter(DataField.LabelStyleProperty, innerStyle));

                dataFormApp.dataForm.DataFieldStyle = style;
            });

            // Wait for a short time to allow the fields to re-generate their UI.
            this.EnqueueDelay(100);

            this.EnqueueCallback(() =>
            {
                Label fieldLabel1 = this.DataFormLabels[0] as Label;
                Label fieldLabel2 = this.DataFormLabels[1] as Label;
                Label fieldLabel3 = this.DataFormLabels[2] as Label;

                Assert.IsTrue(this.GetPosition(fieldLabel1).X == this.GetPosition(fieldLabel2).X);
                Assert.IsTrue(this.GetPosition(fieldLabel2).X == this.GetPosition(fieldLabel3).X);
            });

            this.EnqueueTestComplete();
        }
        public void EnsureLabelAlignmentIsCorrect()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;

                dataFormApp.dataForm.CurrentItem = new DataClass();
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                Label fieldLabel1 = this.DataFormLabels[0] as Label;
                Label fieldLabel2 = this.DataFormLabels[1] as Label;
                Label fieldLabel3 = this.DataFormLabels[2] as Label;

                Assert.IsTrue(this.GetPosition(fieldLabel1).X + fieldLabel1.ActualWidth == this.GetPosition(fieldLabel2).X + fieldLabel2.ActualWidth);
                Assert.IsTrue(this.GetPosition(fieldLabel2).X + fieldLabel2.ActualWidth == this.GetPosition(fieldLabel3).X + fieldLabel3.ActualWidth);

                Style innerStyle = new Style(typeof(Label));
                innerStyle.Setters.Add(new Setter(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Left));
                Style style = new Style(typeof(DataField));
                style.Setters.Add(new Setter(DataField.LabelStyleProperty, innerStyle));

                dataFormApp.dataForm.DataFieldStyle = style;
            });

            // Wait for a short time to allow the fields to re-generate their UI.
            this.EnqueueDelay(100);

            this.EnqueueCallback(() =>
            {
                Label fieldLabel1 = this.DataFormLabels[0] as Label;
                Label fieldLabel2 = this.DataFormLabels[1] as Label;
                Label fieldLabel3 = this.DataFormLabels[2] as Label;

                Assert.IsTrue(this.GetPosition(fieldLabel1).X == this.GetPosition(fieldLabel2).X);
                Assert.IsTrue(this.GetPosition(fieldLabel2).X == this.GetPosition(fieldLabel3).X);
            });

            this.EnqueueTestComplete();
        }
        public void EnsureBeginEditThenCommitItemEditWithInvalidObjectDoesNotEndEdit()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();

            // DataClassWithValidation starts out with a blank StringProperty, which makes it start in an invalid state
            // if that property is not set.
            dataFormApp.dataForm.CurrentItem = new DataClassWithValidation();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                dataFormApp.dataForm.BeginEdit();
                dataFormApp.dataForm.CommitEdit(true /* exitEditingMode */);
                Assert.IsTrue(dataFormApp.dataForm.IsEditing);
            });

            this.EnqueueTestComplete();
        }
        public void EnsureShortNameFallbackApplied()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.CurrentItem = new DataClassWithShortNames();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                Assert.AreEqual("Bool Property", dataFormApp.dataForm.Fields[0].InternalLabel.Content);
                Assert.AreEqual("Date Time Property", dataFormApp.dataForm.Fields[1].InternalLabel.Content);
                Assert.AreEqual("String Property", dataFormApp.dataForm.Fields[2].InternalLabel.Content);
                Assert.AreEqual("Int Property", dataFormApp.dataForm.Fields[4].InternalLabel.Content);
            });

            this.EnqueueTestComplete();
        }
        public void EnsureNoButtonsCausesHeaderToDisappear()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.ItemsSource = DataClassList.GetDataClassList(3, ListOperations.All);
            dataFormApp.dataForm.CommandButtonsVisibility = DataFormCommandButtonsVisibility.None;

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                Assert.AreEqual(Visibility.Collapsed, dataFormApp.dataForm.HeaderVisibility);
                dataFormApp.dataForm.CommandButtonsVisibility = DataFormCommandButtonsVisibility.All;
                Assert.AreEqual(Visibility.Visible, dataFormApp.dataForm.HeaderVisibility);
                dataFormApp.dataForm.CommandButtonsVisibility = DataFormCommandButtonsVisibility.None;
                Assert.AreEqual(Visibility.Collapsed, dataFormApp.dataForm.HeaderVisibility);
                dataFormApp.dataForm.HeaderVisibility = Visibility.Visible;
                Assert.AreEqual(Visibility.Visible, dataFormApp.dataForm.HeaderVisibility);
            });

            this.EnqueueTestComplete();
        }
        public void EnsureReadOnlyAttributeOnPropertyHonored()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.ItemsSource =
                new List<DataClassWithReadOnlyAttribute>()
                {
                    new DataClassWithReadOnlyAttribute(),
                    new DataClassWithReadOnlyAttribute()
                };

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                this.ExpectContentLoaded();
                dataFormApp.dataForm.BeginEdit();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                Assert.IsFalse(dataFormApp.dataForm.Fields[0].IsReadOnly);
                Assert.IsTrue(dataFormApp.dataForm.Fields[1].IsReadOnly);
                Assert.IsFalse(dataFormApp.dataForm.Fields[2].IsReadOnly);

                this.ExpectContentLoaded();
                dataFormApp.dataForm.CancelEdit();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                this.ExpectContentLoaded();
                dataFormApp.dataForm.AddNewItem();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                Assert.IsFalse(dataFormApp.dataForm.Fields[0].IsReadOnly);
                Assert.IsTrue(dataFormApp.dataForm.Fields[1].IsReadOnly);
                Assert.IsFalse(dataFormApp.dataForm.Fields[2].IsReadOnly);
            });

            this.EnqueueTestComplete();
        }
        public void SetLabelPositionAtRuntime()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.CurrentItem = new DataClass();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                Assert.AreEqual(HorizontalAlignment.Right, (this.DataFormLabels[0] as Label).HorizontalAlignment);

                this.ExpectContentLoaded();
                DataField field = dataFormApp.dataForm.Fields[0];
                field.LabelPosition = DataFieldLabelPosition.Top;
                this.ExpectFieldContentLoaded(field);
            });

            this.WaitForFieldContentLoaded();

            this.EnqueueCallback(() =>
            {
                Assert.AreEqual(HorizontalAlignment.Left, (this.DataFormLabels[0] as Label).HorizontalAlignment);
            });

            this.EnqueueTestComplete();
        }
        public void EnsureForegroundPropagates()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.CurrentItem = new DataClass();
            dataFormApp.dataForm.Foreground = new SolidColorBrush(Colors.Red);

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                foreach (DataField field in dataFormApp.dataForm.Fields)
                {
                    Assert.AreEqual(Colors.Red, (field.Foreground as SolidColorBrush).Color);
                }
            });

            this.EnqueueTestComplete();
        }
        public void MoveCurrencyToNullWhenAppending()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();

            List<DataClassWithValidation> dataClassList =
                new List<DataClassWithValidation>()
                {
                    new DataClassWithValidation()
                    {
                        StringProperty = "string 1"
                    }
                };

            PagedCollectionView pcv = new PagedCollectionView(dataClassList);

            this.EnqueueCallback(() =>
            {
                dataFormApp.dataForm.ItemsSource = pcv;
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                this.ExpectCurrentItemChange();
                dataFormApp.dataForm.AddNewItem();
            });

            this.WaitForCurrentItemChange();

            this.EnqueueCallback(() =>
            {
                Assert.AreEqual(2, pcv.Count);
                this.ExpectCurrentItemChange();
                pcv.MoveCurrentToPosition(-1);
            });

            this.WaitForCurrentItemChange();

            this.EnqueueCallback(() =>
            {
                Assert.AreEqual(1, pcv.Count);
            });

            this.EnqueueTestComplete();
        }
        public void EnsureFindNameWorksInAllModes()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.ItemsSource = DataClassList.GetDataClassList(3, ListOperations.All);
            dataFormApp.dataForm.ContentLoaded += new EventHandler<DataFormContentLoadEventArgs>(this.OnDataFormContentLoaded);

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                this.ExpectContentLoaded();
                dataFormApp.dataForm.BeginEdit();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                this.ExpectContentLoaded();
                dataFormApp.dataForm.CancelEdit();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                this.ExpectContentLoaded();
                dataFormApp.dataForm.AddNewItem();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                this.ExpectContentLoaded();
                dataFormApp.dataForm.CancelEdit();
            });

            this.EnqueueTestComplete();
        }
        public void EnsureExceptionThrownWhenCurrencyChangesWithValidationError()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            DataClassWithValidation dataClass = new DataClassWithValidation() { StringProperty = "test string 0" };
            dataFormApp.dataForm.CurrentItem = dataClass;

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                this.ExpectContentLoaded();
                dataFormApp.dataForm.BeginEdit();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                TextBox textBox = this.DataFormInputControls[2] as TextBox;
                textBox.Text = string.Empty;
                dataFormApp.dataForm.CommitEdit(true /* exitEditingMode */);
                Assert.IsFalse(dataFormApp.dataForm.IsItemValid);

                bool changingCurrentItemSucceeded = false;

                try
                {
                    dataFormApp.dataForm.CurrentItem = new DataClass();
                    changingCurrentItemSucceeded = true;
                }
                catch (InvalidOperationException)
                {
                }

                Assert.IsFalse(changingCurrentItemSucceeded);
                Assert.AreEqual(dataClass, dataFormApp.dataForm.CurrentItem);
            });

            this.EnqueueTestComplete();
        }
        public void EnsureFieldsAreRemovedWhenRegeneratingUI()
        {
            Panel dataFormRoot = null;
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.AutoEdit = true;
            dataFormApp.dataForm.ItemsSource = DataClassList.GetDataClassList(3, ListOperations.All);

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                dataFormRoot = VisualTreeHelper.GetChild(dataFormApp.dataForm, 0) as Panel;
                Assert.IsNotNull(dataFormRoot);
                Assert.AreEqual(7, (dataFormRoot.GetValue(DataField.GroupedFieldListProperty) as IList<DataField>).Count);
                dataFormApp.dataForm.BeginEdit();
                Assert.AreEqual(7, (dataFormRoot.GetValue(DataField.GroupedFieldListProperty) as IList<DataField>).Count);
                this.ExpectContentLoaded();
                dataFormApp.dataForm.CancelEdit();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                Assert.AreEqual(7, (dataFormRoot.GetValue(DataField.GroupedFieldListProperty) as IList<DataField>).Count);
            });

            this.EnqueueTestComplete();
        }
        public void EnsureExceptionThrownWhenCurrencyChangesWhenEditingWithAutoCommitFalse()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.AutoCommit = false;
            DataClassWithValidation dataClass = new DataClassWithValidation() { StringProperty = "test string 0" };
            dataFormApp.dataForm.CurrentItem = dataClass;

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                this.ExpectContentLoaded();
                dataFormApp.dataForm.BeginEdit();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                TextBox textBox = this.DataFormInputControls[2] as TextBox;
                textBox.Text = "new string";
                BindingExpression bindingExpression = textBox.GetBindingExpression(TextBox.TextProperty);

                Assert.IsNotNull(bindingExpression);
                bindingExpression.UpdateSource();

                bool changingCurrentItemSucceeded = false;

                try
                {
                    dataFormApp.dataForm.CurrentItem = new DataClass();
                    changingCurrentItemSucceeded = true;
                }
                catch (InvalidOperationException)
                {
                }

                Assert.IsFalse(changingCurrentItemSucceeded);
                Assert.AreEqual(dataClass, dataFormApp.dataForm.CurrentItem);
            });

            this.EnqueueTestComplete();
        }
        public void SetTextBoxToLongContent()
        {
            TextBox textBox = null;
            double previousTextBoxWidth = 0;
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.CurrentItem = new DataClass();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                textBox = this.DataFormInputControls[2] as TextBox;
                previousTextBoxWidth = textBox.ActualWidth;
                textBox.Text = "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong";
            });

            // Give the text box time to change its size if it's going to.
            this.EnqueueDelay(100);

            this.EnqueueCallback(() =>
            {
                Assert.AreEqual(previousTextBoxWidth, textBox.ActualWidth);
            });

            this.EnqueueTestComplete();
        }
        public void SetLabelPositionTwice()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                dataFormApp.dataForm.LabelPosition = DataFieldLabelPosition.Top;
                dataFormApp.dataForm.LabelPosition = DataFieldLabelPosition.Left;
            });

            this.EnqueueTestComplete();
        }
        public void LabelPositionLeftWithInnerTop()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;

                dataFormApp.dataForm.CurrentItem = new DataClass();
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                Label fieldLabel1 = this.DataFormLabels[0] as Label;
                CheckBox checkBox = this.DataFormInputControls[0] as CheckBox;

                Assert.IsTrue(this.GetPosition(fieldLabel1).X < this.GetPosition(checkBox).X);

                Label fieldLabel2 = this.DataFormLabels[1] as Label;
                DatePicker datePicker = this.DataFormInputControls[1] as DatePicker;

                Assert.IsTrue(this.GetPosition(fieldLabel2).X < this.GetPosition(datePicker).X);

                Label fieldLabel3 = this.DataFormLabels[2] as Label;
                TextBox textBox = this.DataFormInputControls[2] as TextBox;

                Assert.IsTrue(this.GetPosition(fieldLabel3).X < this.GetPosition(textBox).X);

                Label fieldLabel4 = this.DataFormLabels[3] as Label;
                TextBlock textBlock = this.DataFormInputControls[3] as TextBlock;

                Assert.IsTrue(this.GetPosition(fieldLabel4).Y < this.GetPosition(textBlock).Y);

                Label fieldLabel5 = this.DataFormLabels[4] as Label;
                ComboBox comboBox = this.DataFormInputControls[4] as ComboBox;

                Assert.IsTrue(this.GetPosition(fieldLabel5).X < this.GetPosition(comboBox).X);

                Label fieldLabel6 = this.DataFormLabels[5] as Label;
                TextBox innerTextBox1 = this.DataFormInputControls[5] as TextBox;

                Assert.IsTrue(this.GetPosition(fieldLabel6).X < this.GetPosition(innerTextBox1).X);

                Label fieldLabel7 = this.DataFormLabels[6] as Label;
                TextBox innerTextBox2 = this.DataFormInputControls[6] as TextBox;

                Assert.IsTrue(this.GetPosition(fieldLabel7).X < this.GetPosition(innerTextBox2).X);
            });

            this.EnqueueTestComplete();
        }
        public void EnsureFirstEditableFieldFocused()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.CurrentItem = new DataClass();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                this.ExpectContentLoaded();
                ButtonBase editButton = this.GetTemplatePart<ButtonBase>("EditButton");
                InvokeButton(editButton);
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                Assert.AreEqual(this.DataFormInputControls[0], FocusManager.GetFocusedElement());
            });

            this.EnqueueTestComplete();
        }
        public void EnsureFindNameInContentWorksInAllModes()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.ItemsSource = DataClassList.GetDataClassList(3, ListOperations.All);

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                Assert.IsNotNull(dataFormApp.dataForm.FindNameInContent("textBox"));
                this.ExpectContentLoaded();
                dataFormApp.dataForm.BeginEdit();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                Assert.IsNotNull(dataFormApp.dataForm.FindNameInContent("textBox"));
                this.ExpectContentLoaded();
                dataFormApp.dataForm.CancelEdit();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                Assert.IsNotNull(dataFormApp.dataForm.FindNameInContent("textBox"));
                this.ExpectContentLoaded();
                dataFormApp.dataForm.AddNewItem();
            });

            this.WaitForContentLoaded();

            this.EnqueueCallback(() =>
            {
                Assert.IsNotNull(dataFormApp.dataForm.FindNameInContent("textBox"));
                this.ExpectContentLoaded();
                dataFormApp.dataForm.CancelEdit();
            });

            this.EnqueueTestComplete();
        }
        public void SetDescriptionViewerStyleAtRuntime()
        {
            DataFormApp_Fields dataFormApp = new DataFormApp_Fields();
            dataFormApp.dataForm.CurrentItem = new DataClass();

            this.EnqueueCallback(() =>
            {
                this.DataFormAppBase = dataFormApp;
            });

            this.AddToPanelAndWaitForLoad();

            this.EnqueueCallback(() =>
            {
                DataField field = dataFormApp.dataForm.Fields[0];
                Style style = new Style(typeof(DescriptionViewer));
                style.Setters.Add(new Setter(DescriptionViewer.FontSizeProperty, 20));
                field.DescriptionViewerStyle = style;
                Assert.AreEqual(20, (this.DataFormDescriptions[0] as DescriptionViewer).FontSize);
            });

            this.EnqueueTestComplete();
        }