fix: 可能发生连续转移

This commit is contained in:
jackfiled 2023-10-23 20:32:44 +08:00
parent ad0b29c10d
commit 2fd587fc6e
2 changed files with 35 additions and 2 deletions

View File

@ -37,6 +37,38 @@ public class YamlDeserializerTests
Assert.Contains(actual.Stages, s => s.Name == "start"); Assert.Contains(actual.Stages, s => s.Name == "start");
Assert.Contains(actual.Stages, s => s.Name == "running"); Assert.Contains(actual.Stages, s => s.Name == "running");
Stage stage = actual.Stages[1];
Assert.Equal("running", stage.Name);
Assert.Contains(stage.Transformers, t => t.NextStageName == "running");
}
[Fact]
public void DeserializerTest2()
{
const string document =
"""
robotName:
stages:
- name: start
answer:
transformers:
- pattern:
nextStageName: running
- pattern: .*?
nextStageName: running
beginStageName: start
""";
IDeserializer deserializer = _factory.GetDeserializer();
LexicalModel actual = deserializer.Deserialize<LexicalModel>(document);
Assert.Contains(actual.Stages, s => s.Name == "start");
Stage stage = actual.Stages[0];
Assert.Contains(stage.Transformers, s => string.IsNullOrEmpty(s.Pattern));
Assert.Contains(stage.Transformers, s => s.Pattern == ".*?");
} }
} }

View File

@ -56,7 +56,8 @@ public class KatheryneChatRobot : IChatRobot
{ {
_currentStage = transformer.NextStage; _currentStage = transformer.NextStage;
result.Add(_grammarTree[_currentStage].Answer); result.Add(_grammarTree[_currentStage].Answer);
_logger.LogDebug("Moving to stage {}.", _currentStage); _logger.LogInformation("Moving to stage {} on input {}.", _currentStage, input);
break;
} }
} }
@ -82,7 +83,7 @@ public class KatheryneChatRobot : IChatRobot
_currentStage = transformer.NextStage; _currentStage = transformer.NextStage;
result.Add(_grammarTree[_currentStage].Answer); result.Add(_grammarTree[_currentStage].Answer);
_logger.LogDebug("Moving to stage {} with empty transform.", _currentStage); _logger.LogInformation("Moving to stage {} with empty transform.", _currentStage);
break; break;
} }
} }