BotSharp/BotSharp.Core.UnitTest/AgentTest.cs

67 lines
1.9 KiB
C#
Raw Normal View History

2018-03-28 22:08:49 +00:00
using BotSharp.Core.Agents;
using BotSharp.Core.Engines;
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;
using Newtonsoft.Json;
2018-03-28 22:08:49 +00:00
using System;
using System.Collections.Generic;
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,
Language = "en"
2018-03-28 22:08:49 +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"
};
var rasa = new RasaAi();
//int row = dc.DbTran(() => rasa.agent.SaveAgent(dc));
2018-03-28 22:08:49 +00:00
}
[TestMethod]
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.Combine(dataPath, "DbInitializer", $"Agents{Path.DirectorySeparatorChar}agents.json");
var agents = JsonConvert.DeserializeObject<List<AgentImportHeader>>(File.ReadAllText(botsHeaderFilePath));
2018-03-28 22:08:49 +00:00
agents.ForEach(agentHeader => {
var bot = new BotSharpAi();
2018-08-28 21:45:56 +00:00
bot.RestoreAgent<AgentImporterInDialogflow>(dataPath);
});
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
{
var rasa = new RasaAi();
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
}
}