Skip to content

Commit 9d1d344

Browse files
committed
test: Updated tests
1 parent 455e35c commit 9d1d344

File tree

4 files changed

+211
-105
lines changed

4 files changed

+211
-105
lines changed

test/Assistant.v1.IntegrationTests/AssistantServiceIntegrationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class AssistantServiceIntegrationTests
3131
{
3232
private AssistantService service;
3333
private static string credentials = string.Empty;
34-
private static string versionDate = "2018-02-16";
34+
private static string versionDate = "2019-02-28";
3535

3636
private static string workspaceId;
3737
private string inputString = "Hello";
@@ -47,7 +47,7 @@ public class AssistantServiceIntegrationTests
4747
private static string createdValue = "value";
4848
private static string createdIntent = "intent";
4949
private static string createdIntentDescription = "Intent created by the .NET SDK Conversation example script.";
50-
private static string createdCounterExampleText = "Example text";
50+
private static string createdCounterExampleText = "Example text?";
5151
private static string createdSynonym = "synonym";
5252
private static string createdExample = "example";
5353
private static string dialogNodeName = "dialognode";
Lines changed: 202 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,222 @@
1-
/**
2-
* Copyright 2017 IBM Corp. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*
16-
*/
17-
18-
using IBM.Watson.Assistant.v2.Model;
19-
using IBM.Cloud.SDK.Core.Util;
20-
using Microsoft.VisualStudio.TestTools.UnitTesting;
21-
using Newtonsoft.Json;
22-
using Newtonsoft.Json.Linq;
23-
using System;
24-
using System.IO;
1+
/**
2+
* Copyright 2017 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using IBM.Watson.Assistant.v2.Model;
19+
using IBM.Cloud.SDK.Core.Util;
20+
using Microsoft.VisualStudio.TestTools.UnitTesting;
21+
using Newtonsoft.Json;
22+
using Newtonsoft.Json.Linq;
23+
using System;
24+
using System.IO;
2525
using IBM.Cloud.SDK.Core.Authentication.Iam;
2626

27-
namespace IBM.Watson.Assistant.v2.IntegrationTests
28-
{
29-
[TestClass]
30-
public class AssistantServiceIntegrationConfigTests
31-
{
32-
private static string apikey;
33-
private static string endpoint;
34-
private AssistantService service;
35-
private static string credentials = string.Empty;
36-
37-
private static string assistantId;
38-
private static string sessionId;
39-
private readonly string inputString = "Hello";
40-
private readonly string versionDate = "2018-09-17";
41-
42-
[TestInitialize]
43-
public void Setup()
44-
{
45-
Utility.LoadExternalCredentials();
46-
var apikey = Environment.GetEnvironmentVariable("ASSISTANT_APIKEY");
47-
var url = Environment.GetEnvironmentVariable("ASSISTANT_URL");
48-
IamConfig iamConfig = new IamConfig(
49-
apikey: apikey
50-
);
51-
service = new AssistantService(versionDate, iamConfig);
52-
service.SetEndpoint(url);
53-
assistantId = Environment.GetEnvironmentVariable("ASSISTANT_ASSISTANT_ID");
54-
}
55-
56-
#region Sessions
57-
[TestMethod]
58-
public void CreateDeleteSession_Success()
59-
{
27+
namespace IBM.Watson.Assistant.v2.IntegrationTests
28+
{
29+
[TestClass]
30+
public class AssistantServiceIntegrationConfigTests
31+
{
32+
private static string apikey;
33+
private static string endpoint;
34+
private AssistantService service;
35+
private static string credentials = string.Empty;
36+
37+
private static string assistantId;
38+
private static string sessionId;
39+
private readonly string inputString0 = "Hello";
40+
private readonly string inputString1 = "Are you open on christmas?";
41+
private readonly string inputString2 = "I'd like to make an appointment.";
42+
private readonly string inputString3 = "Tomorrow at 3pm";
43+
private readonly string inputString4 = "Make that thursday at 2pm";
44+
private readonly string inputString5 = "Who did watson beat in jeopardy?";
45+
private readonly string versionDate = "2019-02-28";
46+
47+
[TestInitialize]
48+
public void Setup()
49+
{
50+
Utility.LoadExternalCredentials();
51+
var apikey = Environment.GetEnvironmentVariable("ASSISTANT_APIKEY");
52+
var url = Environment.GetEnvironmentVariable("ASSISTANT_URL");
53+
IamConfig iamConfig = new IamConfig(
54+
apikey: apikey
55+
);
56+
service = new AssistantService(versionDate, iamConfig);
57+
service.SetEndpoint(url);
58+
assistantId = Environment.GetEnvironmentVariable("ASSISTANT_ASSISTANT_ID");
59+
}
60+
61+
#region Sessions
62+
[TestMethod]
63+
public void CreateDeleteSession_Success()
64+
{
6065
service.WithHeader("X-Watson-Test", "1");
61-
var createSessionResult = service.CreateSession(
62-
assistantId: assistantId
63-
);
64-
sessionId = createSessionResult.Result.SessionId;
65-
66+
var createSessionResult = service.CreateSession(
67+
assistantId: assistantId
68+
);
69+
sessionId = createSessionResult.Result.SessionId;
70+
6671
service.WithHeader("X-Watson-Test", "1");
67-
var deleteSessionResult = service.DeleteSession(
72+
var deleteSessionResult = service.DeleteSession(
6873
assistantId: assistantId,
69-
sessionId: sessionId
70-
);
71-
72-
sessionId = string.Empty;
73-
74-
Assert.IsNotNull(createSessionResult);
75-
Assert.IsNotNull(deleteSessionResult);
76-
Assert.IsTrue(!string.IsNullOrEmpty(createSessionResult.Result.SessionId));
77-
}
78-
#endregion
79-
80-
#region Message
81-
[TestMethod]
82-
public void Message_Success()
83-
{
74+
sessionId: sessionId
75+
);
76+
77+
sessionId = string.Empty;
78+
79+
Assert.IsNotNull(createSessionResult);
80+
Assert.IsNotNull(deleteSessionResult);
81+
Assert.IsTrue(!string.IsNullOrEmpty(createSessionResult.Result.SessionId));
82+
}
83+
#endregion
84+
85+
#region Message
86+
[TestMethod]
87+
public void Message_Success()
88+
{
8489
service.WithHeader("X-Watson-Test", "1");
85-
var createSessionResult = service.CreateSession(
86-
assistantId: assistantId
87-
);
88-
sessionId = createSessionResult.Result.SessionId;
89-
90+
var createSessionResult = service.CreateSession(
91+
assistantId: assistantId
92+
);
93+
sessionId = createSessionResult.Result.SessionId;
94+
9095
MessageInput input = new MessageInput()
9196
{
9297
MessageType = MessageInput.MessageTypeEnumValue.TEXT,
93-
Text = inputString,
98+
Text = inputString0,
9499
Options = new MessageInputOptions()
95100
{
96101
ReturnContext = true,
97102
AlternateIntents = true
98103
}
99-
};
100-
104+
};
105+
101106
service.WithHeader("X-Watson-Test", "1");
102-
var messageResult = service.Message(
107+
var messageResult = service.Message(
103108
assistantId: assistantId,
104109
sessionId: sessionId,
105-
input: input
106-
);
107-
110+
input: input
111+
);
112+
108113
service.WithHeader("X-Watson-Test", "1");
109-
var deleteSessionResult = service.DeleteSession(
114+
var deleteSessionResult = service.DeleteSession(
110115
assistantId: assistantId,
111-
sessionId: sessionId
112-
);
113-
sessionId = string.Empty;
114-
115-
Assert.IsNotNull(createSessionResult);
116-
Assert.IsNotNull(messageResult);
117-
Assert.IsNotNull(deleteSessionResult);
118-
Assert.IsTrue(!string.IsNullOrEmpty(createSessionResult.Result.SessionId));
116+
sessionId: sessionId
117+
);
118+
sessionId = string.Empty;
119+
120+
Assert.IsNotNull(createSessionResult);
121+
Assert.IsNotNull(messageResult);
122+
Assert.IsNotNull(deleteSessionResult);
123+
Assert.IsTrue(!string.IsNullOrEmpty(createSessionResult.Result.SessionId));
124+
}
125+
#endregion
126+
127+
#region MultiMessage
128+
[TestMethod]
129+
public void MultiMessage_Success()
130+
{
131+
service.WithHeader("X-Watson-Test", "1");
132+
var createSessionResult = service.CreateSession(
133+
assistantId: assistantId
134+
);
135+
sessionId = createSessionResult.Result.SessionId;
136+
137+
MessageInput input = new MessageInput()
138+
{
139+
MessageType = MessageInput.MessageTypeEnumValue.TEXT,
140+
Text = inputString0,
141+
Options = new MessageInputOptions()
142+
{
143+
ReturnContext = true,
144+
AlternateIntents = true
145+
}
146+
};
147+
148+
service.WithHeader("X-Watson-Test", "1");
149+
var messageResult0 = service.Message(
150+
assistantId: assistantId,
151+
sessionId: sessionId,
152+
input: input
153+
);
154+
155+
156+
157+
input.Text = inputString1;
158+
159+
service.WithHeader("X-Watson-Test", "1");
160+
var messageResult1 = service.Message(
161+
assistantId: assistantId,
162+
sessionId: sessionId,
163+
input: input
164+
);
165+
166+
input.Text = inputString2;
167+
168+
service.WithHeader("X-Watson-Test", "1");
169+
var messageResult2 = service.Message(
170+
assistantId: assistantId,
171+
sessionId: sessionId,
172+
input: input
173+
);
174+
175+
input.Text = inputString3;
176+
177+
service.WithHeader("X-Watson-Test", "1");
178+
var messageResult3 = service.Message(
179+
assistantId: assistantId,
180+
sessionId: sessionId,
181+
input: input
182+
);
183+
184+
input.Text = inputString4;
185+
186+
service.WithHeader("X-Watson-Test", "1");
187+
var messageResult4 = service.Message(
188+
assistantId: assistantId,
189+
sessionId: sessionId,
190+
input: input
191+
);
192+
193+
input.Text = inputString5;
194+
195+
service.WithHeader("X-Watson-Test", "1");
196+
var messageResult5 = service.Message(
197+
assistantId: assistantId,
198+
sessionId: sessionId,
199+
input: input
200+
);
201+
202+
service.WithHeader("X-Watson-Test", "1");
203+
var deleteSessionResult = service.DeleteSession(
204+
assistantId: assistantId,
205+
sessionId: sessionId
206+
);
207+
sessionId = string.Empty;
208+
209+
Assert.IsNotNull(createSessionResult.Result.SessionId);
210+
Assert.IsNotNull(messageResult0.Result.Output);
211+
Assert.IsNotNull(messageResult1.Result.Output);
212+
Assert.IsNotNull(messageResult2.Result.Output);
213+
Assert.IsNotNull(messageResult3.Result.Output);
214+
Assert.IsNotNull(messageResult4.Result.Output);
215+
Assert.IsNotNull(messageResult5.Result.Output);
216+
Assert.IsTrue(messageResult5.Result.Output.Generic[0].ResponseType == "search");
217+
Assert.IsTrue(deleteSessionResult.StatusCode == 200);
218+
Assert.IsTrue(!string.IsNullOrEmpty(createSessionResult.Result.SessionId));
119219
}
120-
#endregion
121-
}
122-
}
220+
#endregion
221+
}
222+
}

test/Assistant.v2.IntegrationTests/AssistantServiceIntegrationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class AssistantServiceIntegrationTests
3636
private static string assistantId;
3737
private static string sessionId;
3838
private readonly string inputString = "Hello";
39-
private readonly string versionDate = "2018-09-17";
39+
private readonly string versionDate = "2019-02-28";
4040

4141
[TestInitialize]
4242
public void Setup()

test/CompareComply.v1.IntegrationTests/CompareComplyServiceIntegrationTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public void Setup()
4848
{
4949
service = new CompareComplyService();
5050
service.VersionDate = versionDate;
51+
52+
var parentDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.Parent.Parent.Parent.FullName;
53+
string credentialsFilepath = parentDirectory + Path.DirectorySeparatorChar + "sdk-credentials" + Path.DirectorySeparatorChar + "credentials.json";
54+
55+
objectStorageCredentialsInputFilepath = parentDirectory + Path.DirectorySeparatorChar + "sdk-credentials" + Path.DirectorySeparatorChar + "cloud-object-storage-credentials-input.json";
56+
objectStorageCredentialsOutputFilepath = parentDirectory + Path.DirectorySeparatorChar + "sdk-credentials" + Path.DirectorySeparatorChar + "cloud-object-storage-credentials-output.json";
5157
}
5258

5359
#region HTML Conversion

0 commit comments

Comments
 (0)