forked from SciSharp/BotSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAgentTest.cs
More file actions
67 lines (62 loc) · 1.93 KB
/
AgentTest.cs
File metadata and controls
67 lines (62 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using BotSharp.Core.Agents;
using BotSharp.Core.Engines;
using BotSharp.Core.Engines.BotSharp;
using BotSharp.Core.Intents;
using BotSharp.Core.Models;
using EntityFrameworkCore.BootKit;
using Microsoft.EntityFrameworkCore;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace BotSharp.Core.UnitTest
{
[TestClass]
public class AgentTest : TestEssential
{
[TestMethod]
public void CreateAgentTest()
{
var agent = new Agent
{
Id = BOT_ID,
Language = "en",
UserId = Guid.NewGuid().ToString()
};
var rasa = new RasaAi();
//int row = dc.DbTran(() => rasa.agent.SaveAgent(dc));
}
[TestMethod]
public void UpdateAgentTest()
{
var agent = new Agent
{
Id = BOT_ID,
Language = "en"
};
var rasa = new RasaAi();
//int row = dc.DbTran(() => rasa.agent.SaveAgent(dc));
}
[TestMethod]
public void RestoreAgentFromDialogflowToRasaTest()
{
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));
agents.ForEach(agentHeader => {
var bot = new BotSharpAi();
bot.RestoreAgent<AgentImporterInDialogflow>(agentHeader);
});
}
[TestMethod]
public void TrainAgentTest()
{
var rasa = new RasaAi();
rasa.LoadAgent(BOT_ID);
rasa.Train();
}
}
}