88using Microsoft . Bot . Builder ;
99using Microsoft . Bot . Builder . Adapters ;
1010using Microsoft . Bot . Builder . AI . Luis ;
11+ using Microsoft . Bot . Builder . AI . QnA ;
1112using Microsoft . Bot . Builder . Dialogs ;
1213using Microsoft . Bot . Builder . LanguageGeneration ;
1314using Microsoft . Bot . Connector . Authentication ;
2223using $ext_safeprojectname $. Dialogs ;
2324using $ext_safeprojectname $. Models ;
2425using $ext_safeprojectname $. Services ;
26+ using $safeprojectname $. Mocks ;
2527using $safeprojectname $. Utilities ;
2628
2729namespace $safeprojectname $
2830{
2931 public class BotTestBase
3032 {
33+ private const string _knowledgeBaseId = "Chitchat" ;
34+ private const string _endpointKey = "dummy-key" ;
35+ private const string _hostname = "https://dummy-hostname.azurewebsites.net/qnamaker" ;
36+
3137 public IServiceCollection Services { get ; set ; }
3238
3339 public LocaleTemplateManager TestLocaleTemplateManager { get ; set ; }
@@ -63,6 +69,17 @@ public virtual void Initialize()
6369 {
6470 { "General" , GeneralTestUtil . CreateRecognizer ( ) }
6571 } ,
72+ QnAConfiguration = new Dictionary < string , Microsoft . Bot . Builder . AI . QnA . QnAMakerEndpoint >
73+ {
74+ {
75+ "Chitchat" , new QnAMakerEndpoint
76+ {
77+ KnowledgeBaseId = _knowledgeBaseId ,
78+ EndpointKey = _endpointKey ,
79+ Host = _hostname
80+ }
81+ }
82+ }
6683 }
6784 } ,
6885 {
@@ -87,12 +104,6 @@ public virtual void Initialize()
87104 Services . AddSingleton ( new MicrosoftAppCredentials ( "appId" , "password" ) ) ;
88105 Services . AddSingleton ( new UserState ( new MemoryStorage ( ) ) ) ;
89106 Services . AddSingleton ( new ConversationState ( new MemoryStorage ( ) ) ) ;
90- Services . AddSingleton ( sp =>
91- {
92- var userState = sp . GetService < UserState > ( ) ;
93- var conversationState = sp . GetService < ConversationState > ( ) ;
94- return new BotStateSet ( userState , conversationState ) ;
95- } ) ;
96107
97108 // For localization testing
98109 CultureInfo . CurrentUICulture = new CultureInfo ( "en-us" ) ;
@@ -114,12 +125,12 @@ public virtual void Initialize()
114125 TestLocaleTemplateManager = new LocaleTemplateManager ( localizedTemplates , "en-us" ) ;
115126 Services . AddSingleton ( TestLocaleTemplateManager ) ;
116127
117- Services . AddTransient < MainDialog > ( ) ;
128+ Services . AddTransient < MockMainDialog > ( ) ;
118129 Services . AddTransient < OnboardingDialog > ( ) ;
119130 Services . AddTransient < SwitchSkillDialog > ( ) ;
120131 Services . AddTransient < List < SkillDialog > > ( ) ;
121132 Services . AddSingleton < TestAdapter , DefaultTestAdapter > ( ) ;
122- Services . AddTransient < IBot , DefaultActivityHandler < MainDialog > > ( ) ;
133+ Services . AddTransient < IBot , DefaultActivityHandler < MockMainDialog > > ( ) ;
123134
124135 TestUserProfileState = new UserProfileState ( ) ;
125136 TestUserProfileState . Name = "Bot" ;
@@ -130,6 +141,7 @@ public TestFlow GetTestFlow(bool includeUserProfile = true)
130141 var sp = Services . BuildServiceProvider ( ) ;
131142 var adapter = sp . GetService < TestAdapter > ( )
132143 . Use ( new FeedbackMiddleware ( sp . GetService < ConversationState > ( ) , sp . GetService < IBotTelemetryClient > ( ) ) ) ;
144+
133145 var userState = sp . GetService < UserState > ( ) ;
134146 var userProfileState = userState . CreateProperty < UserProfileState > ( nameof ( UserProfileState ) ) ;
135147
0 commit comments