2018-03-28 22:08:49 +00:00
|
|
|
|
using BotSharp.Core.Agents;
|
|
|
|
|
|
using BotSharp.Core.Engines;
|
2018-08-14 22:21:09 +00:00
|
|
|
|
using BotSharp.Core.Engines.BotSharp;
|
2018-06-15 17:39:24 +00:00
|
|
|
|
using BotSharp.Core.Intents;
|
2018-03-28 22:08:49 +00:00
|
|
|
|
using BotSharp.Core.Models;
|
|
|
|
|
|
using EntityFrameworkCore.BootKit;
|
2018-06-15 17:39:24 +00:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2018-03-28 22:08:49 +00:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2018-07-15 12:31:52 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2018-03-28 22:08:49 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2018-06-21 21:30:06 +00:00
|
|
|
|
using System.IO;
|
2018-03-28 22:08:49 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
2018-08-19 03:42:51 +00:00
|
|
|
|
namespace BotSharp.Core.UnitTest
|
2018-03-28 22:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
[TestClass]
|
|
|
|
|
|
public class AgentTest : TestEssential
|
|
|
|
|
|
{
|
|
|
|
|
|
[TestMethod]
|
2018-04-30 03:09:32 +00:00
|
|
|
|
public void CreateAgentTest()
|
2018-03-28 22:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
var agent = new Agent
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = BOT_ID,
|
2018-08-22 21:36:39 +00:00
|
|
|
|
Language = "en"
|
2018-03-28 22:08:49 +00:00
|
|
|
|
};
|
2018-07-15 12:31:52 +00:00
|
|
|
|
var rasa = new RasaAi();
|
|
|
|
|
|
//int row = dc.DbTran(() => rasa.agent.SaveAgent(dc));
|
2018-03-28 22:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2018-04-06 22:39:30 +00:00
|
|
|
|
public void UpdateAgentTest()
|
2018-03-28 22:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
|
var agent = new Agent
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = BOT_ID,
|
|
|
|
|
|
Language = "en"
|
|
|
|
|
|
};
|
2018-07-15 12:31:52 +00:00
|
|
|
|
var rasa = new RasaAi();
|
|
|
|
|
|
//int row = dc.DbTran(() => rasa.agent.SaveAgent(dc));
|
2018-03-28 22:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2018-07-15 12:31:52 +00:00
|
|
|
|
public void RestoreAgentFromDialogflowToRasaTest()
|
2018-03-28 22:08:49 +00:00
|
|
|
|
{
|
2018-08-02 21:14:46 +00:00
|
|
|
|
string dataPath = AppDomain.CurrentDomain.GetData("DataPath").ToString();
|
2018-08-15 22:37:23 +00:00
|
|
|
|
var botsHeaderFilePath = Path.Combine(dataPath, "DbInitializer", $"Agents{Path.DirectorySeparatorChar}agents.json");
|
2018-07-15 12:31:52 +00:00
|
|
|
|
var agents = JsonConvert.DeserializeObject<List<AgentImportHeader>>(File.ReadAllText(botsHeaderFilePath));
|
2018-03-28 22:08:49 +00:00
|
|
|
|
|
2018-07-15 12:31:52 +00:00
|
|
|
|
agents.ForEach(agentHeader => {
|
2018-08-14 22:21:09 +00:00
|
|
|
|
var bot = new BotSharpAi();
|
2018-08-27 21:04:00 +00:00
|
|
|
|
bot.RestoreAgent<AgentImporterInDialogflow>();
|
2018-07-15 12:31:52 +00:00
|
|
|
|
});
|
2018-03-28 22:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2018-04-06 22:39:30 +00:00
|
|
|
|
public void TrainAgentTest()
|
2018-03-28 22:08:49 +00:00
|
|
|
|
{
|
2018-07-15 12:31:52 +00:00
|
|
|
|
var rasa = new RasaAi();
|
2018-07-19 03:31:17 +00:00
|
|
|
|
rasa.LoadAgent(BOT_ID);
|
2018-07-12 15:07:05 +00:00
|
|
|
|
rasa.Train();
|
2018-06-18 14:15:54 +00:00
|
|
|
|
}
|
2018-03-28 22:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|