public async Task State_CustomStateManagerTest() { string testGuid = Guid.NewGuid().ToString(); TestAdapter adapter = new TestAdapter() .Use(new CustomKeyState(new MemoryStorage())); await new TestFlow(adapter, async(context) => { var customState = CustomKeyState.Get(context); switch (context.Request.AsMessageActivity().Text) { case "set value": customState.CustomString = testGuid; context.Reply("value saved"); break; case "get value": context.Reply(customState.CustomString); break; } } ) .Test("set value", "value saved") .Test("get value", testGuid.ToString()) .StartTest(); }
public async Task State_CustomStateManagerTest() { var testGuid = Guid.NewGuid().ToString(); var customState = new CustomKeyState(new MemoryStorage()); var testProperty = customState.CreateProperty <TestPocoState>("test"); var adapter = new TestAdapter() .Use(new AutoSaveStateMiddleware(customState)); await new TestFlow(adapter, async(context, cancellationToken) => { var test = await testProperty.GetAsync(context, () => new TestPocoState()); switch (context.Activity.AsMessageActivity().Text) { case "set value": test.Value = testGuid; await context.SendActivityAsync("value saved"); break; case "get value": await context.SendActivityAsync(test.Value); break; } } ) .Test("set value", "value saved") .Test("get value", testGuid.ToString()) .StartTestAsync(); }