public static void LoadRulesFromFile(KnowledgeBaseWithRules knowledgeBase, Stream stream) { using CommandReader commandReader = new CommandReader(stream); while (!commandReader.EndOfStream) { string command = commandReader.ReadNextCommand(); if (string.IsNullOrWhiteSpace(command)) { continue; } var rule = knowledgeBase.PRead(command); // Unit test // TODO: move this test to project with tests var test = $"якщо {rule.ToString().Replace(")", "").Replace("(", "").ToLower()}"; if (test != command.ToLower()) { throw new Exception(); } knowledgeBase.Rules.AddFirst(rule); } }