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

/V1/spikes/AGCompositeApplicationLibrary/AGComposite.Tests/Events/SubscriptionTokenFixture.cs

#
C# | 72 lines | 43 code | 13 blank | 16 comment | 0 complexity | 94b5eadd94430da7fdb41fe9f7aab3b3 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.Events;
  18. using Microsoft.VisualStudio.TestTools.UnitTesting;
  19. namespace Microsoft.Practices.Composite.Tests.Events
  20. {
  21. [TestClass]
  22. public class SubscriptionTokenFixture
  23. {
  24. [TestMethod]
  25. public void EqualsShouldReturnFalseIfSubscriptionTokenPassedIsNull()
  26. {
  27. SubscriptionToken token = new SubscriptionToken();
  28. Assert.IsFalse(token.Equals(null));
  29. }
  30. [TestMethod]
  31. public void EqualsShouldReturnTrueWhenTokenIsTheSame()
  32. {
  33. SubscriptionToken token = new SubscriptionToken();
  34. Assert.IsTrue(token.Equals(token));
  35. }
  36. [TestMethod]
  37. public void EqualsShouldReturnTrueWhenComparingSameObjectInstances()
  38. {
  39. SubscriptionToken token = new SubscriptionToken();
  40. object tokenObject = token;
  41. Assert.IsTrue(token.Equals(tokenObject));
  42. }
  43. [TestMethod]
  44. public void EqualsShouldReturnFalseWhenComparingDifferentObjectInstances()
  45. {
  46. SubscriptionToken token = new SubscriptionToken();
  47. object tokenObject = new SubscriptionToken();
  48. Assert.IsFalse(token.Equals(tokenObject));
  49. }
  50. [TestMethod]
  51. public void HashCodeIsTheSameForSameToken()
  52. {
  53. SubscriptionToken token = new SubscriptionToken();
  54. int hashCode = token.GetHashCode();
  55. Assert.AreNotEqual(0, hashCode);
  56. Assert.AreEqual(hashCode, token.GetHashCode());
  57. }
  58. }
  59. }