public void TestCopy_ShouldReturnSessionStateCopy() { var sessionState = new SessionState(false); sessionState.AddOrUpdateSubscription(MethodPostTopicPrefix, QualityOfService.AtLeastOnce); sessionState.AddOrUpdateSubscription("Sometopic", QualityOfService.AtLeastOnce); var copySession = sessionState.Copy() as SessionState; Assert.NotNull(copySession); Assert.Equal(copySession.Subscriptions.Count, sessionState.Subscriptions.Count); for (int i = 0; i < copySession.Subscriptions.Count; i++) { Assert.Equal(copySession.Subscriptions[i].TopicFilter, sessionState.Subscriptions[i].TopicFilter); Assert.Equal(copySession.Subscriptions[i].QualityOfService, sessionState.Subscriptions[i].QualityOfService); Assert.Equal(copySession.Subscriptions[i].CreationTime, sessionState.Subscriptions[i].CreationTime); } Assert.Equal(copySession.SubscriptionRegistrations.Count, sessionState.SubscriptionRegistrations.Count); foreach (KeyValuePair <string, bool> subscriptionRegistration in copySession.SubscriptionRegistrations) { Assert.Equal(subscriptionRegistration.Value, sessionState.SubscriptionRegistrations[subscriptionRegistration.Key]); } }