Skip to content

Commit 40a4ba4

Browse files
committed
test: update tests after regeneration
1 parent eaec06c commit 40a4ba4

File tree

4 files changed

+37
-105
lines changed

4 files changed

+37
-105
lines changed

Examples/GenericSerialization.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void Start()
4747
//Log.Debug("GenericSerialization", "main skill: {0}", uDefinedObject["name"]);
4848
//Log.Debug("GenericSerialization", "test: {0}", messageResponse);
4949

50-
var name = messageResponse.Context.Skills["main skill"]["user_defined"]["name"].ToString();
50+
var name = messageResponse.Context.Skills.Skill.UserDefined["name"].ToString();
5151
Log.Debug("GenericSerialization", "name: {0}", name);
5252

5353
}

Tests/AssistantV1IntegrationTests.cs

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public IEnumerator UnityTestSetup()
7171
{
7272
if (service == null)
7373
{
74-
service = new AssistantService(versionDate, authenticator);
74+
service = new AssistantService(versionDate);
7575
}
7676

7777
while (!service.Authenticator.CanAuthenticate())
@@ -88,17 +88,17 @@ public void TestSetup()
8888
public IEnumerator TestMessage()
8989
{
9090
workspaceId = Environment.GetEnvironmentVariable("ASSISTANT_WORKSPACE_ID");
91-
JToken context = null;
91+
Context context = null;
9292
MessageResponse messageResponse = null;
93-
JToken conversationId = null;
93+
string conversationId = null;
9494
Log.Debug("AssistantV1IntegrationTests", "Attempting to Message...{0}...", workspaceId);
9595
service.Message(
9696
callback: (DetailedResponse<MessageResponse> response, IBMError error) =>
9797
{
9898
messageResponse = response.Result;
9999
context = messageResponse.Context;
100-
Log.Debug("AssistantV1IntegrationTests", "result: {0}", messageResponse.Output["generic"][0]["text"]);
101-
(context as JObject).TryGetValue("conversation_id", out conversationId);
100+
Log.Debug("AssistantV1IntegrationTests", "result: {0}", messageResponse.Output.Generic[0].Text);
101+
conversationId = context.ConversationId;
102102
Assert.IsNotNull(context);
103103
Assert.IsNotNull(conversationId);
104104
Assert.IsNull(error);
@@ -113,26 +113,30 @@ public IEnumerator TestMessage()
113113
service.WithHeader("X-Watson-Test", "1");
114114

115115
messageResponse = null;
116-
JObject input = new JObject();
117-
JToken conversationId1 = null;
116+
MessageInput input = new MessageInput();
117+
string conversationId1 = null;
118+
context.Add("name", "watson");
118119
input.Add("text", "Are you open on Christmas?");
120+
119121
Log.Debug("AssistantV1IntegrationTests", "Attempting to Message...Are you open on Christmas?");
120122
service.Message(
121123
callback: (DetailedResponse<MessageResponse> response, IBMError error) =>
122124
{
125+
Context context1 = null;
123126
messageResponse = response.Result;
124-
context = messageResponse.Context;
125-
Log.Debug("AssistantV1IntegrationTests", "result: {0}", messageResponse.Output["generic"][0]["text"]);
126-
(context as JObject).TryGetValue("conversation_id", out conversationId1);
127+
context1 = messageResponse.Context;
128+
Log.Debug("AssistantV1IntegrationTests", "result: {0}", messageResponse.Output.Generic[0].Text);
129+
conversationId1 = context1.ConversationId;
127130

131+
Assert.AreEqual(context1.Get("name"), context.Get("name"));
128132
Assert.IsNotNull(context);
129133
Assert.IsNotNull(conversationId1);
130-
Assert.IsTrue(conversationId1.ToString() == conversationId.ToString());
134+
Assert.IsTrue(conversationId1 == conversationId);
131135
Assert.IsNull(error);
132136
},
133137
workspaceId: workspaceId,
134138
input: input,
135-
context: context as JObject,
139+
context: context,
136140
nodesVisitedDetails: true
137141
);
138142

@@ -142,17 +146,17 @@ public IEnumerator TestMessage()
142146
service.WithHeader("X-Watson-Test", "1");
143147

144148
messageResponse = null;
145-
input = new JObject();
146-
JToken conversationId2 = null;
149+
input = new MessageInput();
150+
string conversationId2 = null;
147151
input.Add("text", "What are your hours?");
148152
Log.Debug("AssistantV1IntegrationTests", "Attempting to Message...What are your hours?");
149153
service.Message(
150154
callback: (DetailedResponse<MessageResponse> response, IBMError error) =>
151155
{
152156
messageResponse = response.Result;
153157
context = messageResponse.Context;
154-
Log.Debug("AssistantV1IntegrationTests", "result: {0}", messageResponse.Output["generic"][0]["text"]);
155-
(context as JObject).TryGetValue("conversation_id", out conversationId2);
158+
Log.Debug("AssistantV1IntegrationTests", "result: {0}", messageResponse.Output.Generic[0].Text);
159+
conversationId2 = context.ConversationId;
156160

157161
Assert.IsNotNull(context);
158162
Assert.IsNotNull(conversationId2);
@@ -161,7 +165,7 @@ public IEnumerator TestMessage()
161165
},
162166
workspaceId: workspaceId,
163167
input: input,
164-
context: context as JObject,
168+
context: context,
165169
nodesVisitedDetails: true
166170
);
167171

@@ -171,17 +175,17 @@ public IEnumerator TestMessage()
171175
service.WithHeader("X-Watson-Test", "1");
172176

173177
messageResponse = null;
174-
input = new JObject();
175-
JToken conversationId3 = null;
178+
input = new MessageInput();
179+
string conversationId3 = null;
176180
input.Add("text", "I'd like to make an appointment for 12pm.");
177181
Log.Debug("AssistantV1IntegrationTests", "Attempting to Message...I'd like to make an appointment for 12pm.");
178182
service.Message(
179183
callback: (DetailedResponse<MessageResponse> response, IBMError error) =>
180184
{
181185
messageResponse = response.Result;
182186
context = messageResponse.Context;
183-
Log.Debug("AssistantV1IntegrationTests", "result: {0}", messageResponse.Output["generic"][0]["text"]);
184-
(context as JObject).TryGetValue("conversation_id", out conversationId3);
187+
Log.Debug("AssistantV1IntegrationTests", "result: {0}", messageResponse.Output.Generic[0].Text);
188+
conversationId3 = context.ConversationId;
185189

186190
Assert.IsNotNull(context);
187191
Assert.IsNotNull(conversationId3);
@@ -190,7 +194,7 @@ public IEnumerator TestMessage()
190194
},
191195
workspaceId: workspaceId,
192196
input: input,
193-
context: context as JObject,
197+
context: context,
194198
nodesVisitedDetails: true
195199
);
196200

@@ -200,17 +204,17 @@ public IEnumerator TestMessage()
200204
service.WithHeader("X-Watson-Test", "1");
201205

202206
messageResponse = null;
203-
input = new JObject();
204-
JToken conversationId4 = null;
207+
input = new MessageInput();
208+
string conversationId4 = null;
205209
input.Add("text", "On Friday please.");
206210
Log.Debug("AssistantV1IntegrationTests", "Attempting to Message...On Friday please.");
207211
service.Message(
208212
callback: (DetailedResponse<MessageResponse> response, IBMError error) =>
209213
{
210214
messageResponse = response.Result;
211215
context = messageResponse.Context;
212-
Log.Debug("AssistantV1IntegrationTests", "result: {0}", messageResponse.Output["generic"][0]["text"]);
213-
(context as JObject).TryGetValue("conversation_id", out conversationId4);
216+
Log.Debug("AssistantV1IntegrationTests", "result: {0}", messageResponse.Output.Generic[0].Text);
217+
conversationId4 = context.ConversationId;
214218

215219
Assert.IsNotNull(context);
216220
Assert.IsNotNull(conversationId4);
@@ -219,7 +223,7 @@ public IEnumerator TestMessage()
219223
},
220224
workspaceId: workspaceId,
221225
input: input,
222-
context: context as JObject,
226+
context: context,
223227
nodesVisitedDetails: true
224228
);
225229

@@ -229,17 +233,17 @@ public IEnumerator TestMessage()
229233
service.WithHeader("X-Watson-Test", "1");
230234

231235
messageResponse = null;
232-
input = new JObject();
233-
JToken conversationId5 = null;
236+
input = new MessageInput();
237+
string conversationId5 = null;
234238
input.Add("text", "Yes.");
235239
Log.Debug("AssistantV1IntegrationTests", "Attempting to Message...Yes.");
236240
service.Message(
237241
callback: (DetailedResponse<MessageResponse> response, IBMError error) =>
238242
{
239243
messageResponse = response.Result;
240244
context = messageResponse.Context;
241-
Log.Debug("AssistantV1IntegrationTests", "result: {0}", messageResponse.Output["generic"][0]["text"]);
242-
(context as JObject).TryGetValue("conversation_id", out conversationId5);
245+
Log.Debug("AssistantV1IntegrationTests", "result: {0}", messageResponse.Output.Generic[0].Text);
246+
conversationId5 = context.ConversationId;
243247

244248
Assert.IsNotNull(context);
245249
Assert.IsNotNull(conversationId5);
@@ -248,7 +252,7 @@ public IEnumerator TestMessage()
248252
},
249253
workspaceId: workspaceId,
250254
input: input,
251-
context: context as JObject,
255+
context: context,
252256
nodesVisitedDetails: true
253257
);
254258

Tests/DiscoveryV1IntegrationTests.cs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -329,41 +329,6 @@ public IEnumerator TestUpdateConfiguration()
329329
}
330330
#endregion
331331

332-
#region TestConfigurationInEnvironment
333-
[UnityTest, Order(8)]
334-
public IEnumerator TestTestConfigurationInEnvironment()
335-
{
336-
Log.Debug("DiscoveryServiceV1IntegrationTests", "Attempting to TestConfigurationInEnvironment...");
337-
TestDocument testConfigurationInEnvironmentResponse = null;
338-
using (FileStream fs = File.OpenRead(watsonBeatsJeopardyHtmlFilePath))
339-
{
340-
using (MemoryStream ms = new MemoryStream())
341-
{
342-
fs.CopyTo(ms);
343-
service.TestConfigurationInEnvironment(
344-
callback: (DetailedResponse<TestDocument> response, IBMError error) =>
345-
{
346-
Log.Debug("DiscoveryServiceV1IntegrationTests", "TestConfigurationInEnvironment result: {0}", response.Response);
347-
testConfigurationInEnvironmentResponse = response.Result;
348-
Assert.IsNotNull(testConfigurationInEnvironmentResponse);
349-
Assert.IsNotNull(testConfigurationInEnvironmentResponse.Status);
350-
Assert.IsNotNull(testConfigurationInEnvironmentResponse.Snapshots);
351-
Assert.IsNull(error);
352-
},
353-
environmentId: environmentId,
354-
configurationId: createdConfigurationId,
355-
file: ms,
356-
fileContentType: Utility.GetMimeType(Path.GetExtension(watsonBeatsJeopardyHtmlFilePath)),
357-
filename: Path.GetFileName(watsonBeatsJeopardyHtmlFilePath)
358-
);
359-
360-
while (testConfigurationInEnvironmentResponse == null)
361-
yield return null;
362-
}
363-
}
364-
}
365-
#endregion
366-
367332
#region CreateCollection
368333
[UnityTest, Order(9)]
369334
public IEnumerator TestCreateCollection()
@@ -886,7 +851,6 @@ public IEnumerator TestFederatedQuery()
886851
},
887852
environmentId: environmentId,
888853
naturalLanguageQuery: "When did Watson win Jeopardy",
889-
collectionIds: collectionId,
890854
passages: true,
891855
count: 10,
892856
highlight: true

Tests/VisualRecognitionV3IntegrationTests.cs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public class VisualRecognitionV3IntegrationTests
4141
private string turtleImageFilepath;
4242
private string turtleImageContentType = "image/jpeg";
4343
private string obamaImageFilepath;
44-
private string obamaImageContentType = "image/jpeg";
4544
private string imageMetadataFilepath;
4645
private string classifierName = "unity-sdk-classifier-safe-to-delete";
4746
private string classifierId;
@@ -161,41 +160,6 @@ public IEnumerator TestClassify()
161160
}
162161
#endregion
163162

164-
#region DetectFaces
165-
[UnityTest, Order(2)]
166-
public IEnumerator TestDetectFaces()
167-
{
168-
Log.Debug("VisualRecognitionServiceV3IntegrationTests", "Attempting to DetectFaces...");
169-
DetectedFaces detectFacesResponse = null;
170-
using (FileStream fs = File.OpenRead(obamaImageFilepath))
171-
{
172-
using (MemoryStream ms = new MemoryStream())
173-
{
174-
fs.CopyTo(ms);
175-
service.DetectFaces(
176-
callback: (DetailedResponse<DetectedFaces> response, IBMError error) =>
177-
{
178-
Log.Debug("VisualRecognitionServiceV3IntegrationTests", "DetectFaces result: {0}", response.Response);
179-
detectFacesResponse = response.Result;
180-
Assert.IsNotNull(detectFacesResponse);
181-
Assert.IsNotNull(detectFacesResponse.Images);
182-
Assert.IsTrue(detectFacesResponse.Images.Count > 0);
183-
Assert.IsNotNull(detectFacesResponse.Images[0].Faces);
184-
Assert.IsTrue(detectFacesResponse.Images[0].Faces.Count > 0);
185-
Assert.IsNull(error);
186-
},
187-
imagesFile: ms,
188-
imagesFileContentType: obamaImageContentType,
189-
imagesFilename: Path.GetFileName(obamaImageFilepath)
190-
);
191-
192-
while (detectFacesResponse == null)
193-
yield return null;
194-
}
195-
}
196-
}
197-
#endregion
198-
199163
#region GetClassifier
200164
//[UnityTest, Order(3)]
201165
public IEnumerator TestGetClassifier()

0 commit comments

Comments
 (0)