PageRenderTime 61ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/V4/PrismLibrary/Silverlight/Prism.Interactivity.Tests/UpdateTextBindingOnPropertyChangedFixture.cs

#
C# | 70 lines | 47 code | 7 blank | 16 comment | 0 complexity | edf5771b40f857f8124c58fc5970c93d MD5 | raw file
  1. //===================================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  4. //===================================================================================
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  7. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  8. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9. // FITNESS FOR A PARTICULAR PURPOSE.
  10. //===================================================================================
  11. // The example companies, organizations, products, domain names,
  12. // e-mail addresses, logos, people, places, and events depicted
  13. // herein are fictitious. No association with any real company,
  14. // organization, product, domain name, email address, logo, person,
  15. // places, or events is intended or should be inferred.
  16. //===================================================================================
  17. using System;
  18. using System.Diagnostics;
  19. using System.Net;
  20. using System.Windows;
  21. using System.Windows.Controls;
  22. using System.Windows.Data;
  23. using System.Windows.Documents;
  24. using System.Windows.Ink;
  25. using System.Windows.Input;
  26. using System.Windows.Media;
  27. using System.Windows.Media.Animation;
  28. using System.Windows.Shapes;
  29. using Microsoft.Practices.Prism.Interactivity;
  30. using Microsoft.Silverlight.Testing;
  31. using Microsoft.VisualStudio.TestTools.UnitTesting;
  32. #pragma warning disable 0618
  33. namespace Prism.Interactivity.Tests
  34. {
  35. [TestClass]
  36. public class UpdateTextBindingOnPropertyChangedFixture : SilverlightTest
  37. {
  38. [TestMethod]
  39. [Asynchronous]
  40. [Timeout(5000)]
  41. public void TestMethod1()
  42. {
  43. var behavior = new UpdateTextBindingOnPropertyChanged();
  44. var bindingSource = new BindingSource() { Value = "InitialValue" };
  45. var binding = new Binding("Value") { Source = bindingSource, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.Explicit };
  46. var textBox = new TextBox();
  47. base.TestPanel.Children.Add(textBox);
  48. EnqueueCallback(() =>
  49. {
  50. textBox.SetBinding(TextBox.TextProperty, binding);
  51. System.Windows.Interactivity.Interaction.GetBehaviors(textBox).Add(behavior);
  52. textBox.Text = "NewValue";
  53. });
  54. EnqueueCallback(() => Assert.AreEqual("NewValue", bindingSource.Value));
  55. EnqueueTestComplete();
  56. }
  57. }
  58. public class BindingSource
  59. {
  60. public string Value { get; set; }
  61. }
  62. }
  63. #pragma warning restore 0618