2018-03-28 22:08:49 +00:00
|
|
|
|
using BotSharp.Core.Agents;
|
|
|
|
|
|
using BotSharp.Core.Engines;
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.UnitTest
|
|
|
|
|
|
{
|
|
|
|
|
|
[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-05-07 00:48:10 +00:00
|
|
|
|
Language = "en",
|
|
|
|
|
|
UserId = Guid.NewGuid().ToString()
|
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();
|
|
|
|
|
|
var botsHeaderFilePath = Path.Join(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 => {
|
|
|
|
|
|
var rasa = new RasaAi();
|
|
|
|
|
|
rasa.RestoreAgent<AgentImporterInDialogflow>(agentHeader);
|
|
|
|
|
|
});
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|