Ejemplo n.º 1
0
        public void ReturnAListWithASingleValueIfOneIsAdded()
        {
            string expectedPattern   = string.Empty.GetRandom();
            string expectedValueType = string.Empty.GetRandom();
            string expectedValue     = string.Empty.GetRandom();

            var target = new IntentEntityValuesBuilder()
                         .Add(expectedValueType, expectedValue, expectedPattern)
                         .Build();

            Assert.Single(target);
        }
Ejemplo n.º 2
0
        public void ReturnAListWithASingleValueAndAnEmptyPatternIfNoPatternIsProvided()
        {
            string expectedValueType = string.Empty.GetRandom();
            string expectedValue     = string.Empty.GetRandom();

            var target = new IntentEntityValuesBuilder()
                         .Add(expectedValueType, expectedValue)
                         .Build();

            var actualValue = target.Single();

            Assert.True(String.IsNullOrWhiteSpace(actualValue.Pattern));
        }
Ejemplo n.º 3
0
        public async Task <Intent> GetIntentAsync(string utterance)
        {
            await Task.Yield();

            var entityValues = new IntentEntityValuesBuilder()
                               .Add("FakeValueType", "FakeValue", "FakePattern")
                               .Build();

            return(new IntentBuilder()
                   .AddName("FakeIntent")
                   .AddScore(0.909579635, 0.0500833727)
                   .AddUtterance(utterance)
                   .AddEntity("FakeEntity", "FakeEntityType", entityValues)
                   .AddResponse($"{{ \"query\": \"{utterance}\", \"topScoringIntent\": {{ \"intent\": \"FakeIntent\", \"score\": 0.909579635 }}, \"intents\": [ {{ \"intent\": \"FakeIntent\", \"score\": 0.909579635 }}, {{ \"intent\": \"AnotherFakeIntent\", \"score\": 0.0500833727 }} ], \"entities\": [ {{ \"entity\": \"april 6th\", \"type\": \"builtin.datetimeV2.date\", \"startIndex\": 20, \"endIndex\": 28, \"resolution\": {{ \"values\": [ {{ \"timex\": \"XXXX-04-06\", \"type\": \"date\", \"value\": \"2017-04-06\" }}, {{ \"timex\": \"XXXX-04-06\", \"type\": \"date\", \"value\": \"2018-04-06\" }} ] }} }} ]}}")
                   .Build());
        }
Ejemplo n.º 4
0
        public void ReturnAnIntentWithAnEntityThatHasASingleValueInTheValuesCollection()
        {
            string expectedName = string.Empty.GetRandom();
            string expectedType = string.Empty.GetRandom();

            string expectedPattern   = string.Empty.GetRandom();
            string expectedValue     = string.Empty.GetRandom();
            string expectedValueType = string.Empty.GetRandom();

            var expectedValues = new IntentEntityValuesBuilder()
                                 .Add(expectedValueType, expectedValue, expectedPattern)
                                 .Build();

            var target = new IntentBuilder();
            var actual = target
                         .AddEntity(expectedName, expectedType, expectedValues)
                         .Build();

            var actualEntity = actual.IntentEntities.Single();
            var actualValue  = actualEntity.Values.Single();

            Assert.Equal(expectedValue, actualValue.Value);
        }
Ejemplo n.º 5
0
        public void ReturnAListWhereTheFirstValueHasTheCorrectPattern()
        {
            string expectedValueType1 = string.Empty.GetRandom();
            string expectedValue1     = string.Empty.GetRandom();
            string expectedPattern1   = string.Empty.GetRandom();

            string expectedValueType2 = string.Empty.GetRandom();
            string expectedValue2     = string.Empty.GetRandom();
            string expectedPattern2   = string.Empty.GetRandom();

            string expectedValueType3 = string.Empty.GetRandom();
            string expectedValue3     = string.Empty.GetRandom();
            string expectedPattern3   = string.Empty.GetRandom();

            var target = new IntentEntityValuesBuilder()
                         .Add(expectedValueType1, expectedValue1, expectedPattern1)
                         .Add(expectedValueType2, expectedValue2, expectedPattern2)
                         .Add(expectedValueType3, expectedValue3, expectedPattern3)
                         .Build();

            var actualValue = target.SingleOrDefault(v => v.Value == expectedValue1);

            Assert.Equal(expectedPattern1, actualValue.Pattern);
        }
Ejemplo n.º 6
0
        public void ReturnAListWithOneInstanceOfTheFirstValue()
        {
            string expectedValueType1 = string.Empty.GetRandom();
            string expectedValue1     = string.Empty.GetRandom();
            string expectedPattern1   = string.Empty.GetRandom();

            string expectedValueType2 = string.Empty.GetRandom();
            string expectedValue2     = string.Empty.GetRandom();
            string expectedPattern2   = string.Empty.GetRandom();

            string expectedValueType3 = string.Empty.GetRandom();
            string expectedValue3     = string.Empty.GetRandom();
            string expectedPattern3   = string.Empty.GetRandom();

            var target = new IntentEntityValuesBuilder()
                         .Add(expectedValueType1, expectedValue1, expectedPattern1)
                         .Add(expectedValueType2, expectedValue2, expectedPattern2)
                         .Add(expectedValueType3, expectedValue3, expectedPattern3)
                         .Build();

            var actualValue = target.SingleOrDefault(v => v.Value == expectedValue1);

            Assert.NotNull(actualValue);
        }
Ejemplo n.º 7
0
        public void ReturnAnEmptyListIfNothingHasBeenAdded()
        {
            var target = new IntentEntityValuesBuilder().Build();

            Assert.False(target.Any());
        }