public async Task SessionStateSeralizationTest() { var sessionState = new SessionState(false); sessionState.AddOrUpdateSubscription(MethodPostTopicPrefix, QualityOfService.AtLeastOnce); sessionState.RemoveSubscription(TwinSubscriptionTopicPrefix); Assert.True(sessionState.SubscriptionRegistrations.ContainsKey(MethodPostTopicPrefix)); Assert.True(sessionState.SubscriptionRegistrations.ContainsKey(TwinSubscriptionTopicPrefix)); Assert.True(sessionState.SubscriptionRegistrations[MethodPostTopicPrefix]); Assert.False(sessionState.SubscriptionRegistrations[TwinSubscriptionTopicPrefix]); IEntityStore <string, SessionState> entityStore = new StoreProvider(new InMemoryDbStoreProvider()).GetEntityStore <string, SessionState>(Constants.SessionStorePartitionKey); string key = Guid.NewGuid().ToString(); await entityStore.Put(key, sessionState); Option <SessionState> retrievedSessionStateOption = await entityStore.Get(key); Assert.True(retrievedSessionStateOption.HasValue); SessionState retrievedSessionState = retrievedSessionStateOption.OrDefault(); Assert.NotNull(retrievedSessionState); Assert.NotNull(retrievedSessionState.Subscriptions); Assert.NotNull(retrievedSessionState.Subscriptions.FirstOrDefault(s => s.TopicFilter == MethodPostTopicPrefix)); Assert.True(retrievedSessionState.SubscriptionRegistrations.ContainsKey(MethodPostTopicPrefix)); Assert.True(retrievedSessionState.SubscriptionRegistrations.ContainsKey(TwinSubscriptionTopicPrefix)); Assert.True(retrievedSessionState.SubscriptionRegistrations[MethodPostTopicPrefix]); Assert.False(retrievedSessionState.SubscriptionRegistrations[TwinSubscriptionTopicPrefix]); }