Esempio n. 1
0
        public async Task TrackActivity_NonIncomingMessage_DoesNotTrackMessageSentiment()
        {
            // Arrange
            var sentimentHttpMock = TestUtils.CreateSentimentHttpMock(50);
            var instrumentation   = new BotFrameworkApplicationInsightsInstrumentation
                                    (
                new InstrumentationSettings
            {
                InstrumentationKeys = new List <string>(new[] { "instrumentation key" }),
                SentimentManager    = new SentimentManager("text analytics api key", "", "", sentimentHttpMock.Object)
            }
                                    );

            // Act
            await instrumentation.TrackActivity(CreateActivity("some text", ActivityTypes.EndOfConversation));

            // Assert if sentiment analysis endpoint was never called
            sentimentHttpMock.Verify(
                x =>
                x.PostAsync
                (
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <Dictionary <string, string> >(),
                    It.IsAny <byte[]>()
                ),
                Times.Never());
        }
Esempio n. 2
0
        public void TrackLuisIntent_SmokeTest()
        {
            var instrumentation = new BotFrameworkApplicationInsightsInstrumentation
                                  (
                new InstrumentationSettings
            {
                InstrumentationKeys = new List <string>(new[] { "instrumentation key" })
            }
                                  );

            var luisResult = new LuisResult
            {
                TopScoringIntent = new IntentRecommendation
                {
                    Intent = "luis intent",
                    Score  = 70
                },
                Entities = new List <EntityRecommendation>
                {
                    new EntityRecommendation
                    {
                        Entity = "luis entity",
                        Type   = "entity type",
                        Score  = 80,
                        Role   = "entity role"
                    }
                }
            };

            instrumentation.TrackLuisIntent(CreateActivity("some text", ActivityTypes.Message), luisResult);
        }
Esempio n. 3
0
        public async Task TrackActivity_IncomingMessage_TracksMessageSentiment()
        {
            // Arrange
            const string textAnalyticsApiKey         = "text analytics api key";
            const string cognitiveServiceApiEndpoint = "cognitive service api endpoint";
            const string messageText = "message text";

            var sentimentHttpMock = TestUtils.CreateSentimentHttpMock(50);
            var instrumentation   = new BotFrameworkApplicationInsightsInstrumentation
                                    (
                new InstrumentationSettings
            {
                InstrumentationKeys = new List <string>(new[] { "instrumentation key" }),
                SentimentManager    = new SentimentManager(textAnalyticsApiKey, "",
                                                           cognitiveServiceApiEndpoint, sentimentHttpMock.Object)
            }
                                    );

            // Act
            await instrumentation.TrackActivity(CreateActivity(messageText, ActivityTypes.Message));

            // Assert if sentiment analysis endpoint was called with correct params
            sentimentHttpMock.Verify(
                x =>
                x.PostAsync
                (
                    It.Is <string>(s => s == cognitiveServiceApiEndpoint),
                    It.IsAny <string>(),
                    It.Is <Dictionary <string, string> >(d => d.ContainsValue(textAnalyticsApiKey)),
                    It.Is <byte[]>(
                        b => JsonConvert.DeserializeObject <BatchInput>(Encoding.UTF8.GetString(b)).Documents[0]
                        .Text == messageText)
                ),
                Times.Once());
        }
Esempio n. 4
0
        public void TrackQnaEvent_SmokeTest()
        {
            var instrumentation = new BotFrameworkApplicationInsightsInstrumentation
                                  (
                new InstrumentationSettings
            {
                InstrumentationKeys = new List <string>(new[] { "instrumentation key" })
            }
                                  );

            instrumentation.TrackQnaEvent(CreateActivity("some text", ActivityTypes.Message), "user query",
                                          "kb question", "kb answer", 90);
        }
Esempio n. 5
0
        public void GlobalSetup()
        {
            _defaultInstrumentation =
                new BotFrameworkApplicationInsightsInstrumentation
                (
                    new InstrumentationSettings
            {
                InstrumentationKeys       = new List <string>(new[] { "instrumentation key" }),
                OmitUsernameFromTelemetry = false,
                SentimentManager          = GetSentimentManager()
            }
                );

            SetupActivity();
            SetupCustomProperties();
            SetupLuisResult();
        }
Esempio n. 6
0
        public void TrackCustomEvent_SmokeTest()
        {
            var instrumentation = new BotFrameworkApplicationInsightsInstrumentation
                                  (
                new InstrumentationSettings
            {
                InstrumentationKeys = new List <string>(new[] { "instrumentation key" })
            }
                                  );

            var customProperties = new Dictionary <string, string>();

            for (var i = 0; i < 10; i++)
            {
                customProperties.Add("key" + i, "value " + i);
            }

            instrumentation.TrackCustomEvent(CreateActivity("some text", ActivityTypes.Message),
                                             customEventProperties: customProperties);
        }