Exemplo n.º 1
0
        public async Task BotStateGet()
        {
            var turnContext = TestUtilities.CreateEmptyContext();

            turnContext.Activity.Conversation = new ConversationAccount {
                Id = "1234"
            };

            var storage = new MemoryStorage(new Dictionary <string, JObject>());

            // This was changed from ConversationSate to TestBotState
            // because TestBotState has a context service key
            // that is different from the name of its type
            var botState = new TestBotState(storage);

            (await botState
             .CreateProperty <TestPocoState>("test-name")
             .GetAsync(turnContext, () => new TestPocoState())).Value = "test-value";

            var json = botState.Get(turnContext);

            Assert.AreEqual("test-value", json["test-name"]["Value"].ToString());
        }