PageRenderTime 39ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/V2.2/trunk/CAL/Desktop/Composite.Presentation.Tests/Regions/RegionBehaviorCollectionFixture.cs

#
C# | 59 lines | 35 code | 8 blank | 16 comment | 0 complexity | 2ecc49960b1b1b93e4b451726acfb4ae 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 Microsoft.Practices.Composite.Presentation.Regions;
  18. using Microsoft.Practices.Composite.Presentation.Tests.Mocks;
  19. using Microsoft.VisualStudio.TestTools.UnitTesting;
  20. namespace Microsoft.Practices.Composite.Presentation.Tests.Regions
  21. {
  22. [TestClass]
  23. public class RegionBehaviorCollectionFixture
  24. {
  25. [TestMethod]
  26. public void CanAttachRegionBehaviors()
  27. {
  28. RegionBehaviorCollection behaviorCollection = new RegionBehaviorCollection(new MockRegion());
  29. var mock1 = new MockRegionBehavior();
  30. bool mock1Attached = false;
  31. mock1.OnAttach = () => mock1Attached = true;
  32. behaviorCollection.Add("Mock1", mock1);
  33. var mock2 = new MockRegionBehavior();
  34. bool mock2Attached = false;
  35. mock2.OnAttach = () => mock2Attached = true;
  36. behaviorCollection.Add("Mock2", mock2);
  37. Assert.IsTrue(mock1Attached);
  38. Assert.IsTrue(mock2Attached);
  39. }
  40. [TestMethod]
  41. public void ShouldAddRegionWhenAddingBehavior()
  42. {
  43. var region = new MockRegion();
  44. RegionBehaviorCollection behaviorCollection = new RegionBehaviorCollection(region);
  45. var behavior = new MockRegionBehavior();
  46. behaviorCollection.Add("Mock", behavior);
  47. Assert.IsNotNull(behavior.Region);
  48. Assert.AreSame(region, behavior.Region);
  49. }
  50. }
  51. }