public static IContainer Build(ConversationTestBase testContext, params object[] singletons) { var builder = new ContainerBuilder(); builder.RegisterModule(new DialogModule()); builder .RegisterType <BotToUserQueue>() .Keyed <IBotToUser>(FiberModule.Key_DoNotSerialize) .AsSelf() .As <IBotToUser>() .InstancePerLifetimeScope(); builder .Register((c, p) => testContext) .As <IConnectorClientFactory>() .InstancePerLifetimeScope(); builder .Register((c, p) => new SendLastInline_BotToUser(p.TypedAs <Message>(), c.Resolve <IConnectorClient>())) .Keyed <IBotToUser>(FiberModule.Key_DoNotSerialize) .AsSelf() .As <IBotToUser>() .InstancePerLifetimeScope(); foreach (var singleton in singletons) { builder .Register(c => singleton) .Keyed <object>(FiberModule.Key_DoNotSerialize); } return(builder.Build()); }
public static IContainer Build(ConversationTestBase testContext, params object[] singletons) { var builder = new ContainerBuilder(); builder.RegisterModule(new DialogModule()); builder .Register((c, p) => testContext) .As <IConnectorClientFactory>() .InstancePerLifetimeScope(); foreach (var singleton in singletons) { builder .Register(c => singleton) .Keyed(FiberModule.Key_DoNotSerialize, singleton.GetType()); } return(builder.Build()); }
public static Mock <IBots> MockIBots(ConversationTestBase testContext) { var botsClient = new Moq.Mock <IBots>(MockBehavior.Loose); botsClient.Setup(d => d.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(botId, conversationId, data, headers, token) => { return(testContext.UpsertData(botId, null, conversationId, data)); }); botsClient.Setup(d => d.GetConversationDataWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .Returns <string, string, Dictionary <string, List <string> >, CancellationToken>(async(botId, conversationId, headers, token) => { return(testContext.GetData(botId, null, conversationId)); }); botsClient.Setup(d => d.SetUserDataWithHttpMessagesAsync(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(botId, userId, data, headers, token) => { return(testContext.UpsertData(botId, userId, null, data)); }); botsClient.Setup(d => d.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(botId, userId, headers, token) => { return(testContext.GetData(botId, userId, null)); }); botsClient.Setup(d => d.SetPerUserInConversationDataWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <BotData>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .Returns <string, string, string, BotData, Dictionary <string, List <string> >, CancellationToken>(async(botId, conversationId, userId, data, headers, token) => { return(testContext.UpsertData(botId, userId, conversationId, data)); }); botsClient.Setup(d => d.GetPerUserConversationDataWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>())) .Returns <string, string, string, Dictionary <string, List <string> >, CancellationToken>(async(botId, conversationId, userId, headers, token) => { return(testContext.GetData(botId, userId, conversationId)); }); return(botsClient); }