private static void SetConversationDataWithHttpMessagesAsync(MockConnectorFactory mockConnectorFactory, Mock <StateClient> botsClient) { botsClient .Setup(d => d.BotState.SetConversationDataWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <BotData>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .Returns <string, string, BotData, Dictionary <string, List <string> >, CancellationToken>(async(channelId, conversationId, data, headers, token) => { return(await mockConnectorFactory.UpdateAndInsertData(channelId, null, conversationId, BotStoreType.BotConversationData, data)); }); }
private static void GetUserDataWithHttpMessagesAsync(MockConnectorFactory mockConnectorFactory, Mock <StateClient> botsClient) { botsClient .Setup(d => d.BotState.GetUserDataWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .Returns <string, string, Dictionary <string, List <string> >, CancellationToken>(async(channelId, userId, headers, token) => { return(await mockConnectorFactory.GetData(channelId, userId, null, BotStoreType.BotUserData)); }); }
/// <summary> /// Mocks a Stateclient. /// </summary> /// <param name="mockConnectorFactory">A <see cref="MockConnectorFactory"/>.</param> /// <returns>A mocked version of StateClient.</returns> public static Mock <StateClient> MockIBots(MockConnectorFactory mockConnectorFactory) { var botsClient = new Mock <StateClient>(MockBehavior.Loose); SetConversationDataWithHttpMessagesAsync(mockConnectorFactory, botsClient); GetConversationDataWithHttpMessagesAsync(mockConnectorFactory, botsClient); SetUserDataWithHttpMessagesAsync(mockConnectorFactory, botsClient); GetUserDataWithHttpMessagesAsync(mockConnectorFactory, botsClient); SetPrivateConversationDataWithHttpMessagesAsync(mockConnectorFactory, botsClient); GetPrivateConversationDataWithHttpMessagesAsync(mockConnectorFactory, botsClient); return(botsClient); }