PageRenderTime 13ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 2ms 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
18
19using Microsoft.Practices.Composite.Events;
20using Microsoft.VisualStudio.TestTools.UnitTesting;
21
22namespace Microsoft.Practices.Composite.Tests.Events
23{
24    [TestClass]
25    public class SubscriptionTokenFixture
26    {
27        [TestMethod]
28        public void EqualsShouldReturnFalseIfSubscriptionTokenPassedIsNull()
29        {
30            SubscriptionToken token = new SubscriptionToken();
31            Assert.IsFalse(token.Equals(null));
32        }
33
34        [TestMethod]
35        public void EqualsShouldReturnTrueWhenTokenIsTheSame()
36        {
37            SubscriptionToken token = new SubscriptionToken();
38            Assert.IsTrue(token.Equals(token));
39        }
40
41        [TestMethod]
42        public void EqualsShouldReturnTrueWhenComparingSameObjectInstances()
43        {
44            SubscriptionToken token = new SubscriptionToken();
45
46            object tokenObject = token;
47
48            Assert.IsTrue(token.Equals(tokenObject));
49        }
50
51        [TestMethod]
52        public void EqualsShouldReturnFalseWhenComparingDifferentObjectInstances()
53        {
54            SubscriptionToken token = new SubscriptionToken();
55
56            object tokenObject = new SubscriptionToken();
57
58            Assert.IsFalse(token.Equals(tokenObject));
59        }
60
61        [TestMethod]
62        public void HashCodeIsTheSameForSameToken()
63        {
64            SubscriptionToken token = new SubscriptionToken();
65            int hashCode = token.GetHashCode();
66
67            Assert.AreNotEqual(0, hashCode);
68            Assert.AreEqual(hashCode, token.GetHashCode());
69        }
70
71    }
72}