public void TestFallbackNoEditOrInsertTemplate() { DataFormApp_Templates dataFormApp = new DataFormApp_Templates(); this.DataFormAppBase = dataFormApp; dataFormApp.dataForm.EditTemplate = null; dataFormApp.dataForm.NewItemTemplate = null; dataFormApp.dataForm.ItemsSource = DataClassList.GetDataClassList(1, ListOperations.All); ContentPresenter contentPresenter = null; this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { contentPresenter = this.GetTemplatePart <ContentPresenter>("ContentPresenter"); ButtonBase editButton = this.GetTemplatePart <ButtonBase>("EditButton"); ButtonBase newItemButton = this.GetTemplatePart <ButtonBase>("NewItemButton"); TextBox textBox = contentPresenter.Content as TextBox; Assert.IsNotNull(textBox); Assert.AreEqual("Display Template", textBox.Text); Assert.IsTrue(dataFormApp.dataForm.EffectiveIsReadOnly); Assert.IsFalse(editButton.IsEnabled); Assert.IsFalse(newItemButton.IsEnabled); }); this.EnqueueTestComplete(); }
public void EnsureTemplatePartsThroughProperties() { DataFormApp_LayoutProperties dataFormApp = new DataFormApp_LayoutProperties(); dataFormApp.dataForm.FontFamily = new FontFamily("Arial"); dataFormApp.dataForm.FontSize = 15; this.DataFormAppBase = dataFormApp; dataFormApp.dataForm.ItemsSource = DataClassList.GetDataClassList(3, ListOperations.All); this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { ButtonBase newItemButton = this.GetTemplatePart <ButtonBase>("NewItemButton"); ButtonBase deleteItemButton = this.GetTemplatePart <ButtonBase>("DeleteItemButton"); ButtonBase cancelButton = this.GetTemplatePart <ButtonBase>("CancelButton"); ButtonBase editButton = this.GetTemplatePart <ButtonBase>("EditButton"); ButtonBase commitButton = this.GetTemplatePart <ButtonBase>("CommitButton"); ContentControl headerElement = this.GetTemplatePart <ContentControl>("HeaderElement"); Assert.AreEqual(Visibility.Collapsed, newItemButton.Visibility); Assert.AreEqual(Visibility.Visible, deleteItemButton.Visibility); Assert.AreEqual(Visibility.Collapsed, editButton.Visibility); Assert.AreEqual("Cancel button", cancelButton.Content); Assert.AreEqual("Commit button", commitButton.Content); Assert.AreEqual(15, headerElement.FontSize); Assert.AreEqual("Arial", headerElement.FontFamily.Source); Assert.IsNotNull(dataFormApp.dataForm.ValidationSummary); Assert.IsNotNull(dataFormApp.dataForm.ValidationSummary.Style); Assert.AreEqual(20, dataFormApp.dataForm.ValidationSummary.FontSize); }); this.EnqueueTestComplete(); }
public void TestFallbackNoTemplates() { DataFormApp_Templates dataFormApp = new DataFormApp_Templates(); this.DataFormAppBase = dataFormApp; dataFormApp.dataForm.NewItemTemplate = null; dataFormApp.dataForm.EditTemplate = null; dataFormApp.dataForm.ReadOnlyTemplate = null; dataFormApp.dataForm.ItemsSource = DataClassList.GetDataClassList(1, ListOperations.All); ContentPresenter contentPresenter = null; this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { contentPresenter = this.GetTemplatePart <ContentPresenter>("ContentPresenter"); ButtonBase newItemButton = this.GetTemplatePart <ButtonBase>("NewItemButton"); this.ExpectCurrentItemChange(); InvokeButton(newItemButton); }); this.WaitForCurrentItemChange(); this.EnqueueCallback(() => { TextBox textBox = contentPresenter.Content as TextBox; Assert.IsNotNull(textBox); Assert.AreEqual("Direct Content", textBox.Text); Assert.AreEqual(dataFormApp.dataForm.Content, textBox); }); this.EnqueueTestComplete(); }
/// <summary> /// Initializes the test framework. /// </summary> public override void Initialize() { base.Initialize(); this.DataFormAppBase = new DataFormApp_Standard(); this.dataClassList = DataClassList.GetDataClassList(3, ListOperations.All); this.DataForm.ItemsSource = this.dataClassList; }
public void SetValuesWithAutomationPeers() { DataClass dataClass = null; IInvokeProvider invokeProvider; this.EnqueueCallback(() => { dataClass = DataClassList.GetDataClassList(1, ListOperations.All)[0]; this.DataForm.CurrentItem = dataClass; }); this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { this.GetAutomationPeer(); this.GetChildAutomationPeers(); Assert.AreEqual(true, dataClass.BoolProperty); Assert.AreEqual("test string 0", dataClass.StringProperty); invokeProvider = this._editButtonAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; this.ExpectContentLoaded(); invokeProvider.Invoke(); }); this.WaitForContentLoaded(); this.EnqueueCallback(() => { this.GetChildAutomationPeers(); IToggleProvider toggleProvider = (this._inputControlAutomationPeers[0] as CheckBoxAutomationPeer).GetPattern(PatternInterface.Toggle) as IToggleProvider; IValueProvider valueProvider = (this._inputControlAutomationPeers[2] as TextBoxAutomationPeer).GetPattern(PatternInterface.Value) as IValueProvider; toggleProvider.Toggle(); valueProvider.SetValue("new string"); invokeProvider = this._commitButtonAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; this.ExpectContentLoaded(); invokeProvider.Invoke(); }); this.WaitForContentLoaded(); this.EnqueueCallback(() => { Assert.AreEqual(false, dataClass.BoolProperty); Assert.AreEqual("new string", dataClass.StringProperty); }); this.EnqueueTestComplete(); }
public void ItemsSource() { VerifyDependencyPropertyWithName( "ItemsSource", typeof(IEnumerable), true /* expectGet */, true /* expectSet */, true /* hasCallback */, this.dataForm, new Collection <string>(), new List <int>(), DataClassList.GetDataClassList(10, ListOperations.All)); }
public void EnsureUIUpdatedAfterEditDirectContent() { DataFormApp_DirectContent dataFormApp = new DataFormApp_DirectContent(); this.DataFormAppBase = dataFormApp; dataFormApp.dataForm.ItemsSource = DataClassList.GetDataClassList(1, ListOperations.All); ContentPresenter contentPresenter = null; this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { contentPresenter = this.GetTemplatePart <ContentPresenter>("ContentPresenter"); ButtonBase editButton = this.GetTemplatePart <ButtonBase>("EditButton"); this.ExpectBeginEdit(); InvokeButton(editButton); }); this.WaitForBeginEdit(); this.EnqueueCallback(() => { ButtonBase commitButton = this.GetTemplatePart <ButtonBase>("CommitButton"); TextBox textBox = contentPresenter.Content as TextBox; Assert.IsNotNull(textBox); Assert.AreEqual(dataFormApp.dataForm.Content, textBox); Assert.AreEqual(DataFormMode.Edit, dataFormApp.dataForm.Mode); textBox.Text = "new string"; this.ExpectEditEnded(); InvokeButton(commitButton); }); this.WaitForEditEnded(); this.EnqueueCallback(() => { TextBox textBox = contentPresenter.Content as TextBox; Assert.IsNotNull(textBox); Assert.AreEqual(dataFormApp.dataForm.Content, textBox); Assert.AreEqual(DataFormMode.ReadOnly, dataFormApp.dataForm.Mode); Assert.AreEqual("new string", textBox.Text); }); this.EnqueueTestComplete(); }
public void TestIsControlElement() { this.EnqueueCallback(() => { this.DataForm.CurrentItem = DataClassList.GetDataClassList(1, ListOperations.All)[0]; }); this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { this.GetAutomationPeer(); Assert.IsTrue(this._dataFormAutomationPeer.IsControlElement()); }); this.EnqueueTestComplete(); }
public void EnsureClassNameIsCorrect() { this.EnqueueCallback(() => { this.DataForm.CurrentItem = DataClassList.GetDataClassList(1, ListOperations.All)[0]; }); this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { this.GetAutomationPeer(); Assert.AreEqual("DataForm", this._dataFormAutomationPeer.GetClassName()); }); this.EnqueueTestComplete(); }
public void EnsureCannotInsertWithIsReadOnly() { this.dataClassList = DataClassList.GetDataClassList(3, ListOperations.All); this.DataForm.IsReadOnly = true; this.DataForm.ItemsSource = this.dataClassList; this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { Assert.IsFalse(this.DataForm.CanAddItems); ButtonBase newItemButton = this.GetTemplatePart <ButtonBase>("NewItemButton"); Assert.IsFalse(newItemButton.IsEnabled); }); this.EnqueueTestComplete(); }
public void AutoGeneratingField() { DataFormApp_AutoGeneration dataFormApp = new DataFormApp_AutoGeneration(); this.DataFormAppBase = dataFormApp; dataFormApp.dataForm.ItemsSource = DataClassList.GetDataClassList(2, ListOperations.All); this.EnqueueCallback(() => { this.ExpectEvent <DataFormAutoGeneratingFieldEventArgs>("AutoGeneratingField"); dataFormApp.dataForm.AutoGenerateFields = true; }); this.AddToPanelAndWaitForLoad(); this.WaitForAllEvents(); this.EnqueueTestComplete(); }
public void TestIsKeyboardFocusable() { this.EnqueueCallback(() => { this.DataForm.CurrentItem = DataClassList.GetDataClassList(1, ListOperations.All)[0]; }); this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { this.GetAutomationPeer(); Assert.IsTrue(this._dataFormAutomationPeer.IsKeyboardFocusable()); this.DataForm.IsEnabled = false; Assert.IsFalse(this._dataFormAutomationPeer.IsKeyboardFocusable()); }); this.EnqueueTestComplete(); }
public void EnsureElementNameBindingWorks() { DataFormApp_TemplatesWithElementNameBinding dataFormApp = new DataFormApp_TemplatesWithElementNameBinding(); this.DataFormAppBase = dataFormApp; dataFormApp.dataForm.ItemsSource = DataClassList.GetDataClassList(1, ListOperations.All); this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { ContentPresenter contentPresenter = this.GetTemplatePart <ContentPresenter>("ContentPresenter"); StackPanel stackPanel = contentPresenter.Content as StackPanel; Label fieldLabel = stackPanel.Children[0] as Label; Assert.AreEqual("String Property", fieldLabel.Content); DescriptionViewer descriptionViewer = stackPanel.Children[2] as DescriptionViewer; Assert.AreEqual("String Property Description", descriptionViewer.Description); }); this.EnqueueTestComplete(); }
public void EnsureCanAddAndDeleteWithInitialAutoEdit() { DataFormApp_FieldsWithInitialAutoEdit dataFormApp = new DataFormApp_FieldsWithInitialAutoEdit(); this.DataFormAppBase = dataFormApp; this.dataClassList = DataClassList.GetDataClassList(5, ListOperations.All); dataFormApp.dataForm.CurrentItem = this.dataClassList[0]; dataFormApp.dataForm.ItemsSource = this.dataClassList; this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { dataFormApp.dataForm.BeginEdit(); Assert.IsTrue(dataFormApp.dataForm.CanAddItems); Assert.IsTrue(dataFormApp.dataForm.CanDeleteItems); }); this.EnqueueTestComplete(); }
public void EnsureCanCancelAfterAddWithAutoEdit() { this.DataForm.ItemsSource = DataClassList.GetDataClassList(1, ListOperations.All); this.DataForm.AutoEdit = true; this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { this.ExpectContentLoaded(); this.DataForm.AddNewItem(); }); this.WaitForContentLoaded(); this.EnqueueCallback(() => { Assert.IsTrue(this.GetTemplatePart <ButtonBase>("CancelButton").IsEnabled); }); this.EnqueueTestComplete(); }
public void EnsureGroupingDoesNotChangeOrder() { this.EnqueueCallback(() => { DataClassList dataClassList = DataClassList.GetDataClassList(2, ListOperations.All); PagedCollectionView pcv = new PagedCollectionView(dataClassList); pcv.GroupDescriptions.Add(new PropertyGroupDescription("StringProperty")); this.DataForm.ItemsSource = pcv; this.DataForm.AutoEdit = false; }); this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { Assert.AreEqual(5, this.DataForm.Fields.Count); Binding[] bindings = this.GetBindings(); Assert.AreEqual("BoolProperty", bindings[0].Path.Path); Assert.IsTrue(bindings[0].ValidatesOnExceptions); Assert.IsTrue(bindings[0].NotifyOnValidationError); Assert.IsInstanceOfType(this.DataForm.Fields[0].Content, typeof(CheckBox)); Assert.AreEqual("DateTimeProperty", bindings[1].Path.Path); Assert.IsTrue(bindings[1].ValidatesOnExceptions); Assert.IsTrue(bindings[1].NotifyOnValidationError); Assert.IsInstanceOfType(this.DataForm.Fields[1].Content, typeof(DatePicker)); Assert.AreEqual("IntProperty", bindings[2].Path.Path); Assert.IsTrue(bindings[2].ValidatesOnExceptions); Assert.IsTrue(bindings[2].NotifyOnValidationError); Assert.IsInstanceOfType(this.DataForm.Fields[2].Content, typeof(TextBox)); Assert.AreEqual("IntPropertyWithoutAutoGenerateField", bindings[3].Path.Path); Assert.IsTrue(bindings[3].ValidatesOnExceptions); Assert.IsTrue(bindings[3].NotifyOnValidationError); Assert.IsInstanceOfType(this.DataForm.Fields[3].Content, typeof(TextBox)); Assert.AreEqual("StringProperty", bindings[4].Path.Path); Assert.IsTrue(bindings[4].ValidatesOnExceptions); Assert.IsTrue(bindings[4].NotifyOnValidationError); Assert.IsInstanceOfType(this.DataForm.Fields[4].Content, typeof(TextBox)); this.ExpectContentLoaded(); this.DataForm.CurrentIndex = 1; }); this.WaitForContentLoaded(); this.EnqueueCallback(() => { Assert.AreEqual(5, this.DataForm.Fields.Count); Binding[] bindings = this.GetBindings(); Assert.AreEqual("BoolProperty", bindings[0].Path.Path); Assert.IsTrue(bindings[0].ValidatesOnExceptions); Assert.IsTrue(bindings[0].NotifyOnValidationError); Assert.IsInstanceOfType(this.DataForm.Fields[0].Content, typeof(CheckBox)); Assert.AreEqual("DateTimeProperty", bindings[1].Path.Path); Assert.IsTrue(bindings[1].ValidatesOnExceptions); Assert.IsTrue(bindings[1].NotifyOnValidationError); Assert.IsInstanceOfType(this.DataForm.Fields[1].Content, typeof(DatePicker)); Assert.AreEqual("IntProperty", bindings[2].Path.Path); Assert.IsTrue(bindings[2].ValidatesOnExceptions); Assert.IsTrue(bindings[2].NotifyOnValidationError); Assert.IsInstanceOfType(this.DataForm.Fields[2].Content, typeof(TextBox)); Assert.AreEqual("IntPropertyWithoutAutoGenerateField", bindings[3].Path.Path); Assert.IsTrue(bindings[3].ValidatesOnExceptions); Assert.IsTrue(bindings[3].NotifyOnValidationError); Assert.IsInstanceOfType(this.DataForm.Fields[3].Content, typeof(TextBox)); Assert.AreEqual("StringProperty", bindings[4].Path.Path); Assert.IsTrue(bindings[4].ValidatesOnExceptions); Assert.IsTrue(bindings[4].NotifyOnValidationError); Assert.IsInstanceOfType(this.DataForm.Fields[4].Content, typeof(TextBox)); }); this.EnqueueTestComplete(); }
/// <summary> /// Initializes the test framework. /// </summary> /// <summary> /// Initializes the test framework. /// </summary> public override void Initialize() { base.Initialize(); this.DataFormAppBase = new DataFormApp_Templates(); this.DataForm.ItemsSource = DataClassList.GetDataClassList(1, ListOperations.All); }
public void InvokeNavigationButtons() { IInvokeProvider invokeProvider; this.EnqueueCallback(() => { this.DataForm.ItemsSource = DataClassList.GetDataClassList(3, ListOperations.All); }); this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { this.GetAutomationPeer(); this.GetChildAutomationPeers(); Assert.AreEqual(0, this.DataForm.CurrentIndex); invokeProvider = this._nextItemButtonAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; this.ExpectCurrentItemChange(); invokeProvider.Invoke(); }); this.WaitForCurrentItemChange(); this.EnqueueCallback(() => { Assert.AreEqual(1, this.DataForm.CurrentIndex); invokeProvider = this._previousItemButtonAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; this.ExpectCurrentItemChange(); invokeProvider.Invoke(); }); this.WaitForCurrentItemChange(); this.EnqueueCallback(() => { Assert.AreEqual(0, this.DataForm.CurrentIndex); invokeProvider = this._lastItemButtonAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; this.ExpectCurrentItemChange(); invokeProvider.Invoke(); }); this.WaitForCurrentItemChange(); this.EnqueueCallback(() => { Assert.AreEqual(2, this.DataForm.CurrentIndex); invokeProvider = this._firstItemButtonAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; this.ExpectCurrentItemChange(); invokeProvider.Invoke(); }); this.WaitForCurrentItemChange(); this.EnqueueCallback(() => { Assert.AreEqual(0, this.DataForm.CurrentIndex); }); this.EnqueueTestComplete(); }
public void InvokeEditButtons() { IInvokeProvider invokeProvider; this.EnqueueCallback(() => { this.DataForm.ItemsSource = DataClassList.GetDataClassList(3, ListOperations.All); }); this.AddToPanelAndWaitForLoad(); this.EnqueueCallback(() => { this.GetAutomationPeer(); this.GetChildAutomationPeers(); Assert.AreEqual(DataFormMode.ReadOnly, this.DataForm.Mode); invokeProvider = this._editButtonAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; this.ExpectContentLoaded(); invokeProvider.Invoke(); }); this.WaitForContentLoaded(); this.EnqueueCallback(() => { Assert.AreEqual(DataFormMode.Edit, this.DataForm.Mode); DataClass dataClass = (this.DataForm.CurrentItem as DataClass); dataClass.StringProperty = "new string"; invokeProvider = this._commitButtonAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; this.ExpectContentLoaded(); invokeProvider.Invoke(); }); this.WaitForContentLoaded(); this.EnqueueCallback(() => { Assert.AreEqual(DataFormMode.ReadOnly, this.DataForm.Mode); invokeProvider = this._editButtonAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; this.ExpectContentLoaded(); invokeProvider.Invoke(); }); this.WaitForContentLoaded(); this.EnqueueCallback(() => { Assert.AreEqual(DataFormMode.Edit, this.DataForm.Mode); invokeProvider = this._cancelButtonAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; this.ExpectContentLoaded(); invokeProvider.Invoke(); }); this.WaitForContentLoaded(); this.EnqueueCallback(() => { Assert.AreEqual(DataFormMode.ReadOnly, this.DataForm.Mode); }); this.EnqueueTestComplete(); }