/// <summary> /// Ctor /// </summary> /// <param name="userKey">The GUID of the user</param> /// <param name="bot">the bot the user is connected to</param> public User(IUserPredicateService userPredicateService, IUserResultService userResultService, IUserRequestService requestService) { _predicates = userPredicateService; _results = userResultService; //bot.DefaultPredicates.Clone(Predicates); _requestService = requestService; _predicates.addSetting("topic", "*"); _converter = new BotConverter(_requestService); }
/// <summary> /// Ctor /// </summary> public Bot(IBotConfigurationLoader configurationLoader, ILogger logger, IBotUserService botUserService, IUserResultService resultService, IAimlLoader loader, IUserPredicateService predicateService, IUserRequestService requestService, IApplicationService applicationService) { _logger = logger; _botUserService = botUserService; _userResultService = resultService; _loader = loader; _predicateService = predicateService; _requestService = requestService; _applicationService = applicationService; _configurationLoader = configurationLoader; _graphmaster = new Node(); }
public void TestChat() { var serviceProvider = new ServiceCollection() .AddLogging() .BuildServiceProvider(); var factory = serviceProvider.GetService <ILoggerFactory>(); var logger = factory.CreateLogger <Bot>(); int userId = 1; var mockUserService = new Mock <IBotUserService>(); mockUserService.Setup(x => x.GetTopic(It.IsAny <int>())).Returns(""); var mockResultService = new Mock <IUserResultService>(); mockResultService.Setup(x => x.GetLastOutput(It.IsAny <int>())).Returns(""); var mockPredicateService = new Mock <IUserPredicateService>(); var mockRequestService = new Mock <IUserRequestService>(); IBotConfigurationLoader configurationLoader = new ConfigurationLoader(); IBotUserService botUserService = mockUserService.Object; IUserResultService resultService = mockResultService.Object; IUserPredicateService predicateService = mockPredicateService.Object; IUserRequestService requestService = mockRequestService.Object; IApplicationService applicationService = GetMockAppService(); SettingsDictionary substitutions = new SettingsDictionary(); string inputString = ""; Normalize.ApplySubstitutions substitutor = new Normalize.ApplySubstitutions(substitutions, inputString); Regex strippers = new Regex("[^0-9a-zA-Z]"); Normalize.StripIllegalCharacters stripper = new Normalize.StripIllegalCharacters(strippers); IAimlLoader loader = new AIMLLoader(logger, substitutor, stripper, true, 1000); Bot bot = new Bot(configurationLoader, logger, botUserService, resultService, loader, predicateService, requestService, applicationService); bot.Initialize(); string expectedResult = "Because I am a piece of software."; var result = bot.Chat(new Request("Why do you live in a computer?", userId)); Assert.NotNull(result); Assert.Equal(expectedResult, result.Output); }
public UserResultController(IUserResultService userResultService, IMapper mapper) { this.userResultService = userResultService; this.mapper = mapper; }