/// <summary> /// Cancels an edit. /// </summary> public void CancelEdit() { if (this.oldDataClass != null) { this.BoolProperty = this.oldDataClass.boolProperty; this.DateTimeProperty = this.oldDataClass.dateTimeProperty; this.IntProperty = this.oldDataClass.intProperty; this.IntPropertyWithoutAutoGenerateField = this.oldDataClass.intPropertyWithoutAutoGenerateField; this.NonGeneratedIntProperty = this.oldDataClass.nonGeneratedIntProperty; this.StringProperty = this.oldDataClass.stringProperty; this.oldDataClass = null; } }
/// <summary> /// Ends an edit. /// </summary> public void EndEdit() { this.oldDataClass = null; }
/// <summary> /// Initializes the unchanged data class used in IRevertableChangeTracking. /// </summary> private void EnsureUnchangedDataClass() { if (this.unchangedDataClass == null) { this.unchangedDataClass = new DataClass(); this.unchangedDataClass.boolProperty = this.boolProperty; this.unchangedDataClass.dateTimeProperty = this.dateTimeProperty; this.unchangedDataClass.intProperty = this.intProperty; this.unchangedDataClass.intPropertyWithoutAutoGenerateField = this.intPropertyWithoutAutoGenerateField; this.unchangedDataClass.nonGeneratedIntProperty = this.nonGeneratedIntProperty; this.unchangedDataClass.stringProperty = this.stringProperty; } }
/// <summary> /// Begins an edit. /// </summary> public void BeginEdit() { if (this.oldDataClass == null) { this.oldDataClass = new DataClass(); this.oldDataClass.boolProperty = this.boolProperty; this.oldDataClass.dateTimeProperty = this.dateTimeProperty; this.oldDataClass.intProperty = this.intProperty; this.oldDataClass.intPropertyWithoutAutoGenerateField = this.intPropertyWithoutAutoGenerateField; this.oldDataClass.nonGeneratedIntProperty = this.nonGeneratedIntProperty; this.oldDataClass.stringProperty = this.stringProperty; } }
/// <summary> /// Removes an item. /// </summary> /// <param name="item">The data class.</param> public void Remove(DataClass item) { this.dataClassList.Remove(item); }
/// <summary> /// Returns a new <see cref="DataClass"/> entity list. /// </summary> /// <param name="count">The number of items to be put in the list.</param> /// <param name="supportedOperations">The supported operations for the list.</param> /// <returns>The entity list.</returns> public static DataClassList GetDataClassList(int count, ListOperations supportedOperations) { DataClassList dataClassList = new DataClassList(); for (int i = 0; i < count; i++) { DataClass dataClass = new DataClass() { BoolProperty = (i % 2 == 0), DateTimeProperty = new DateTime(2000 + i, 1 + (i % 12), 1 + (i % 28)), IntProperty = i * 3, IntPropertyWithoutAutoGenerateField = (i * 3) + 1, NonGeneratedIntProperty = (i * 3) + 2, StringProperty = "test string " + i.ToString(CultureInfo.CurrentCulture) }; dataClass.AcceptChanges(); dataClassList.Add(dataClass); } dataClassList.supportedOperations = supportedOperations; return dataClassList; }
/// <summary> /// Cancel an edit. /// </summary> /// <param name="item">The data class.</param> public void CancelEdit(DataClass item) { item.CancelEdit(); }
/// <summary> /// Ends an edit. /// </summary> /// <param name="item">The data class.</param> public void EndEdit(DataClass item) { item.EndEdit(); }
/// <summary> /// Begins an edit. /// </summary> /// <param name="item">The data class.</param> public void BeginEdit(DataClass item) { item.BeginEdit(); }
/// <summary> /// Adds an item. /// </summary> /// <param name="item">The data class.</param> public void Add(DataClass item) { this.dataClassList.Add(item); }
/// <summary> /// Initializes the test framework. /// </summary> public override void Initialize() { base.Initialize(); this.DataFormAppBase = new DataFormApp_Fields(); this.dataClass = DataClassList.GetDataClassList(1, ListOperations.All)[0]; this.DataForm.CurrentItem = this.dataClass; }
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(); }