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); }
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)); }
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()); }
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); }
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); }
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); }
public void ReturnAnEmptyListIfNothingHasBeenAdded() { var target = new IntentEntityValuesBuilder().Build(); Assert.False(target.Any()); }