public async Task <IIntent> PerformAsync(CancellationToken cancellationToken)
        {
            var intentDto = await _userPhrase.RecognizeIntentAsync(cancellationToken);

            if (intentDto.Intent == IntentNames.StartGame)
            {
                return(new StartGameIntent());
            }

            if (intentDto.Intent == IntentNames.KillCharacter)
            {
                //todo add validation of entity type
                return(new KillCharacterIntent(ExtractCharacterFrom(intentDto)));
            }

            if (intentDto.Intent == IntentNames.TalkToCharacter)
            {
                //todo add validation of entity type
                return(new TalkToCharacterIntent(ExtractCharacterFrom(intentDto)));
            }

            if (intentDto.Intent == IntentNames.None)
            {
                //todo add validation of entity type
                return(new WordsIntent(Words.From(EntityValuesIn(intentDto).ToImmutableList())));
            }

            if (intentDto.Intent == IntentNames.QuestionWho)
            {
                //todo add validation of entity type
                return(new QuestionWhoIntent());
            }

            return(new InvalidItent(_player)); //bug is that even needed?
        }
Beispiel #2
0
        public async Task Receives(RecognitionResultDto recognitionResultDto)
        {
            _player = new FakePlayer();
            _userPhrase.RecognizeIntentAsync(Arg.Any <CancellationToken>()).Returns(recognitionResultDto);

            var messageActivity = await _activityFactory.CreateMessageActivityAsync(
                _botPersistentState, _userPhrase, _player, CancellationToken.None);

            await messageActivity.HandleAsync(CancellationToken.None);
        }