This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
MainTests.cs
184 lines (172 loc) · 5.57 KB
/
MainTests.cs
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//
// Copyright (c) 2017 Nick Rimmer. All rights reserved.
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
using ApiAi.Exceptions;
using ApiAi.Models;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ApiAi.Tests
{
[TestClass]
public class MainTests
{
private const string
ClientAccessToken = "your_client_access_token",
DeveloperAccessToken = "your_developer_access_token",
ExampleEntityId = "your_exists_entity_id";
[TestMethod]
public void QueryTest()
{
try
{
var result = QueryService.SendRequest(new ConfigModel { AccesTokenClient = ClientAccessToken }, "some text");
Assert.IsFalse(string.IsNullOrEmpty(result.SessionId));
#pragma warning disable
}catch(ApiAiException ex)
#pragma warning restore
{
// Use debug to check this "ex" value
Assert.Fail();
}
}
[TestMethod]
public void EntitiesListTest()
{
try
{
var result = EntityService.GetEntities(new ConfigModel { AccesTokenDeveloper = DeveloperAccessToken });
Assert.IsTrue(result.Any()); // fail you haven't any entities in the agent, it's ok (;
}
#pragma warning disable
catch (ApiAiException ex)
#pragma warning restore
{
// Use debug to check this "ex" value
Assert.Fail();
}
}
[TestMethod]
public void EntriesListTest()
{
try
{
var result = EntityService.GetEntries(new ConfigModel { AccesTokenDeveloper = DeveloperAccessToken }, ExampleEntityId);
Assert.IsTrue(result.Entries.Any());
}
#pragma warning disable
catch (ApiAiException ex)
#pragma warning restore
{
// Use debug to check this "ex" value
Assert.Fail();
}
}
[TestMethod]
public void EntityCreateTest()
{
try
{
var NewEntityId = EntityService.CreateEntity(new ConfigModel { AccesTokenDeveloper = DeveloperAccessToken }, "test_entity_1", new Dictionary<string, string[]> {
{ "test1", new[]{ "test 1", "test one" } },
{ "test2", new[]{ "test 2", "test second" } }
});
}
#pragma warning disable
catch (ApiAiException ex)
#pragma warning restore
{
// Use debug to check this "ex" value
Assert.Fail();
}
}
[TestMethod]
public void EntityUpdateTest()
{
try
{
EntityService.UpdateEntity(new ConfigModel { AccesTokenDeveloper = DeveloperAccessToken }, ExampleEntityId, "test_entity_1", new Dictionary<string, string[]> {
{ "test1", new[]{ "test 1", "test one" } },
{ "test2", new[]{ "test 2", "test second" } }
});
}
#pragma warning disable
catch (ApiAiException ex)
#pragma warning restore
{
// Use debug to check this "ex" value
Assert.Fail();
}
}
[TestMethod]
public void EntityDeleteTest()
{
try
{
EntityService.DeleteEntity(new ConfigModel { AccesTokenDeveloper = DeveloperAccessToken }, ExampleEntityId);
}
#pragma warning disable
catch (ApiAiException ex)
#pragma warning restore
{
// Use debug to check this "ex" value
Assert.Fail();
}
}
[TestMethod]
public void EntriesAddTest()
{
try
{
EntityService.AddEntries(new ConfigModel { AccesTokenDeveloper = DeveloperAccessToken }, ExampleEntityId, new Dictionary<string, string[]> {
{ "test3", new[]{ "test 3", "test three" } },
{ "test4", new[]{ "test 4", "test four" } }
});
}
#pragma warning disable
catch (ApiAiException ex)
#pragma warning restore
{
// Use debug to check this "ex" value
Assert.Fail();
}
}
[TestMethod]
public void EntriesUpdateTest()
{
try
{
EntityService.UpdateEntries(new ConfigModel { AccesTokenDeveloper = DeveloperAccessToken }, ExampleEntityId, new Dictionary<string, string[]> {
{ "test1", new[]{ "test 1", "test one", "test before second" } },
});
}
#pragma warning disable
catch (ApiAiException ex)
#pragma warning restore
{
// Use debug to check this "ex" value
Assert.Fail();
}
}
[TestMethod]
public void EntriesDeleteTest()
{
try
{
EntityService.DeleteEntries(new ConfigModel { AccesTokenDeveloper = DeveloperAccessToken }, ExampleEntityId, "test1", "test2");
}
#pragma warning disable
catch (ApiAiException ex)
#pragma warning restore
{
// Use debug to check this "ex" value
Assert.Fail();
}
}
}
}