Skip to content

Commit 2bc73d2

Browse files
committed
add a unit test index to select credential index for all unit tests
1 parent c568e58 commit 2bc73d2

19 files changed

+31
-47
lines changed

Examples/ServiceExamples/Scripts/ExampleConversation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void Start()
6969
throw new WatsonException(r.FormattedMessages);
7070

7171
// Set credentials from imported credntials
72-
Credential credential = vcapCredentials.VCAP_SERVICES["conversation"][0].Credentials;
72+
Credential credential = vcapCredentials.VCAP_SERVICES["conversation"][1].Credentials;
7373
_username = credential.Username.ToString();
7474
_password = credential.Password.ToString();
7575
_url = credential.Url.ToString();

Scripts/Editor/Help/Working/obj/Debug.meta

Lines changed: 0 additions & 9 deletions
This file was deleted.

Scripts/UnitTests/TestAlchemyLanguage.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace IBM.Watson.DeveloperCloud.UnitTests
3030
public class TestAlchemyAPI : UnitTest
3131
{
3232
private string _apikey;
33-
private string _url;
3433
private fsSerializer _serializer = new fsSerializer();
3534

3635
private AlchemyAPI _alchemyAPI;
@@ -134,7 +133,7 @@ public override IEnumerator RunTest()
134133
throw new WatsonException(r.FormattedMessages);
135134

136135
// Set credentials from imported credntials
137-
Credential credential = vcapCredentials.VCAP_SERVICES["alchemy_api"][0].Credentials;
136+
Credential credential = vcapCredentials.VCAP_SERVICES["alchemy_api"][TestCredentialIndex].Credentials;
138137
_apikey = credential.Apikey.ToString();
139138
_url = credential.Url.ToString();
140139

Scripts/UnitTests/TestConversation.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public class TestConversation : UnitTest
2929
{
3030
private string _username;
3131
private string _password;
32-
private string _url;
3332
private string _workspaceId;
3433
//private string _token = "<authentication-token>";
3534

@@ -69,7 +68,7 @@ public override IEnumerator RunTest()
6968
throw new WatsonException(r.FormattedMessages);
7069

7170
// Set credentials from imported credntials
72-
Credential credential = vcapCredentials.VCAP_SERVICES["conversation"][0].Credentials;
71+
Credential credential = vcapCredentials.VCAP_SERVICES["conversation"][TestCredentialIndex].Credentials;
7372
_username = credential.Username.ToString();
7473
_password = credential.Password.ToString();
7574
_url = credential.Url.ToString();
@@ -161,6 +160,8 @@ private void OnMessage(object resp, string data)
161160
_context = _tempContext as Dictionary<string, object>;
162161
else
163162
Log.Debug("ExampleConversation", "Failed to get context");
163+
164+
Test(messageResponse != null);
164165
_waitingForResponse = false;
165166
}
166167
}

Scripts/UnitTests/TestDiscovery.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public class TestDiscovery : UnitTest
2929
{
3030
private string _username;
3131
private string _password;
32-
private string _url;
3332
private fsSerializer _serializer = new fsSerializer();
3433
//private string _token = "<authentication-token>";
3534

@@ -98,7 +97,7 @@ public override IEnumerator RunTest()
9897
throw new WatsonException(r.FormattedMessages);
9998

10099
// Set credentials from imported credntials
101-
Credential credential = vcapCredentials.VCAP_SERVICES["discovery"][0].Credentials;
100+
Credential credential = vcapCredentials.VCAP_SERVICES["discovery"][TestCredentialIndex].Credentials;
102101
_username = credential.Username.ToString();
103102
_password = credential.Password.ToString();
104103
_url = credential.Url.ToString();

Scripts/UnitTests/TestDocumentConversion.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public class TestDocumentConversion : UnitTest
3131
private DocumentConversion _documentConversion;
3232
private string _username;
3333
private string _password;
34-
private string _url;
3534
private fsSerializer _serializer = new fsSerializer();
3635
//private string _token = "<authentication-token>";
3736

@@ -66,7 +65,7 @@ public override IEnumerator RunTest()
6665
throw new WatsonException(r.FormattedMessages);
6766

6867
// Set credentials from imported credntials
69-
Credential credential = vcapCredentials.VCAP_SERVICES["document_conversion"][0].Credentials;
68+
Credential credential = vcapCredentials.VCAP_SERVICES["document_conversion"][TestCredentialIndex].Credentials;
7069
_username = credential.Username.ToString();
7170
_password = credential.Password.ToString();
7271
_url = credential.Url.ToString();

Scripts/UnitTests/TestLanguageTranslation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
// {
9090
// Test(translation != null);
9191
// if (translation != null && translation.translations.Length > 0)
92-
// Log.Status("TestTranslate", "Translation: {0}", translation.translations[0].translation);
92+
// Log.Status("TestTranslate", "Translation: {0}", translation.translations[TestCredentialIndex].translation);
9393
// m_TranslateTested = true;
9494
// }
9595

Scripts/UnitTests/TestLanguageTranslator.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public class TestLanguageTranslator : UnitTest
3131
private string _pharseToTranslate = "Hello, welcome to IBM Watson!";
3232
private string _username;
3333
private string _password;
34-
private string _url;
3534
//private string _token = "<authentication-token>";
3635
private fsSerializer _serializer = new fsSerializer();
3736

@@ -76,7 +75,7 @@ public override IEnumerator RunTest()
7675
throw new WatsonException(r.FormattedMessages);
7776

7877
// Set credentials from imported credntials
79-
Credential credential = vcapCredentials.VCAP_SERVICES["language_translator"][0].Credentials;
78+
Credential credential = vcapCredentials.VCAP_SERVICES["language_translator"][TestCredentialIndex].Credentials;
8079
_username = credential.Username.ToString();
8180
_password = credential.Password.ToString();
8281
_url = credential.Url.ToString();

Scripts/UnitTests/TestNaturalLanguageClassifier.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public class TestNaturalLanguageClassifier : UnitTest
3636
{
3737
private string _username;
3838
private string _password;
39-
private string _url;
4039
private fsSerializer _serializer = new fsSerializer();
4140
//private string _token = "<authentication-token>";
4241

@@ -85,7 +84,7 @@ public override IEnumerator RunTest()
8584
throw new WatsonException(r.FormattedMessages);
8685

8786
// Set credentials from imported credntials
88-
Credential credential = vcapCredentials.VCAP_SERVICES["natural_language_classifier"][0].Credentials;
87+
Credential credential = vcapCredentials.VCAP_SERVICES["natural_language_classifier"][TestCredentialIndex].Credentials;
8988
_username = credential.Username.ToString();
9089
_password = credential.Password.ToString();
9190
_url = credential.Url.ToString();

Scripts/UnitTests/TestNaturalLanguageUnderstanding.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public class TestNaturalLanguageUnderstanding : UnitTest
2929
{
3030
private string _username;
3131
private string _password;
32-
private string _url;
3332
private fsSerializer _serializer = new fsSerializer();
3433
//private string _token = "<authentication-token>";
3534

@@ -65,7 +64,7 @@ public override IEnumerator RunTest()
6564
throw new WatsonException(r.FormattedMessages);
6665

6766
// Set credentials from imported credntials
68-
Credential credential = vcapCredentials.VCAP_SERVICES["natural_language_understanding"][0].Credentials;
67+
Credential credential = vcapCredentials.VCAP_SERVICES["natural_language_understanding"][TestCredentialIndex].Credentials;
6968
_username = credential.Username.ToString();
7069
_password = credential.Password.ToString();
7170
_url = credential.Url.ToString();

Scripts/UnitTests/TestPersonalityInsightsV3.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class TestPersonalityInsightsV3 : UnitTest
3232
{
3333
private string _username;
3434
private string _password;
35-
private string _url;
3635
private fsSerializer _serializer = new fsSerializer();
3736

3837
private PersonalityInsights _personalityInsights;
@@ -72,7 +71,7 @@ public override IEnumerator RunTest()
7271
throw new WatsonException(r.FormattedMessages);
7372

7473
// Set credentials from imported credntials
75-
Credential credential = vcapCredentials.VCAP_SERVICES["personality_insights"][0].Credentials;
74+
Credential credential = vcapCredentials.VCAP_SERVICES["personality_insights"][TestCredentialIndex].Credentials;
7675
_username = credential.Username.ToString();
7776
_password = credential.Password.ToString();
7877
_url = credential.Url.ToString();

Scripts/UnitTests/TestRetrieveAndRank.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class TestRetrieveAndRank : UnitTest
3333
{
3434
private string _username;
3535
private string _password;
36-
private string _url;
3736
private fsSerializer _serializer = new fsSerializer();
3837
//private string _token = "<authentication-token>";
3938

@@ -113,7 +112,7 @@ public override IEnumerator RunTest()
113112
throw new WatsonException(r.FormattedMessages);
114113

115114
// Set credentials from imported credntials
116-
Credential credential = vcapCredentials.VCAP_SERVICES["retrieve_and_rank"][0].Credentials;
115+
Credential credential = vcapCredentials.VCAP_SERVICES["retrieve_and_rank"][TestCredentialIndex].Credentials;
117116
_username = credential.Username.ToString();
118117
_password = credential.Password.ToString();
119118
_url = credential.Url.ToString();

Scripts/UnitTests/TestSpeechToText.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class TestSpeechToText : UnitTest
3232
{
3333
private string _username;
3434
private string _password;
35-
private string _url;
3635
private fsSerializer _serializer = new fsSerializer();
3736
//private string _token = "<authentication-token>";
3837

@@ -97,7 +96,7 @@ public override IEnumerator RunTest()
9796
throw new WatsonException(r.FormattedMessages);
9897

9998
// Set credentials from imported credntials
100-
Credential credential = vcapCredentials.VCAP_SERVICES["speech_to_text"][0].Credentials;
99+
Credential credential = vcapCredentials.VCAP_SERVICES["speech_to_text"][TestCredentialIndex].Credentials;
101100
_username = credential.Username.ToString();
102101
_password = credential.Password.ToString();
103102
_url = credential.Url.ToString();

Scripts/UnitTests/TestTextToSpeech.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public class TestTextToSpeech : UnitTest
3030
{
3131
private string _username;
3232
private string _password;
33-
private string _url;
3433
private fsSerializer _serializer = new fsSerializer();
3534
//private string _token = "<authentication-token>";
3635

@@ -85,7 +84,7 @@ public override IEnumerator RunTest()
8584
throw new WatsonException(r.FormattedMessages);
8685

8786
// Set credentials from imported credntials
88-
Credential credential = vcapCredentials.VCAP_SERVICES["text_to_speech"][0].Credentials;
87+
Credential credential = vcapCredentials.VCAP_SERVICES["text_to_speech"][TestCredentialIndex].Credentials;
8988
_username = credential.Username.ToString();
9089
_password = credential.Password.ToString();
9190
_url = credential.Url.ToString();

Scripts/UnitTests/TestToneAnalyzer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public class TestToneAnalyzer : UnitTest
2929
{
3030
private string _username;
3131
private string _password;
32-
private string _url;
3332
private fsSerializer _serializer = new fsSerializer();
3433
//private string _token = "<authentication-token>";
3534

@@ -66,7 +65,7 @@ public override IEnumerator RunTest()
6665
throw new WatsonException(r.FormattedMessages);
6766

6867
// Set credentials from imported credntials
69-
Credential credential = vcapCredentials.VCAP_SERVICES["tone_analyzer"][0].Credentials;
68+
Credential credential = vcapCredentials.VCAP_SERVICES["tone_analyzer"][TestCredentialIndex].Credentials;
7069
_username = credential.Username.ToString();
7170
_password = credential.Password.ToString();
7271
_url = credential.Url.ToString();

Scripts/UnitTests/TestTradeoffAnalytics.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public class TestTradeoffAnalytics : UnitTest
3131
{
3232
private string _username;
3333
private string _password;
34-
private string _url;
3534
private fsSerializer _serializer = new fsSerializer();
3635
//private string _token = "<authentication-token>";
3736

@@ -66,7 +65,7 @@ public override IEnumerator RunTest()
6665
throw new WatsonException(r.FormattedMessages);
6766

6867
// Set credentials from imported credntials
69-
Credential credential = vcapCredentials.VCAP_SERVICES["tradeoff_analytics"][0].Credentials;
68+
Credential credential = vcapCredentials.VCAP_SERVICES["tradeoff_analytics"][TestCredentialIndex].Credentials;
7069
_username = credential.Username.ToString();
7170
_password = credential.Password.ToString();
7271
_url = credential.Url.ToString();

Scripts/UnitTests/TestVisualRecognition.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ namespace IBM.Watson.DeveloperCloud.UnitTests
3535
public class TestVisualRecognition : UnitTest
3636
{
3737
private string _apikey;
38-
private string _url;
3938
private fsSerializer _serializer = new fsSerializer();
4039

4140
private VisualRecognition _visualRecognition;
@@ -91,7 +90,7 @@ public override IEnumerator RunTest()
9190
throw new WatsonException(r.FormattedMessages);
9291

9392
// Set credentials from imported credntials
94-
Credential credential = vcapCredentials.VCAP_SERVICES["visual_recognition"][0].Credentials;
93+
Credential credential = vcapCredentials.VCAP_SERVICES["visual_recognition"][TestCredentialIndex].Credentials;
9594
_apikey = credential.Apikey.ToString();
9695
_url = credential.Url.ToString();
9796

Scripts/UnitTests/UnitTest.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
*
1616
*/
1717

18+
// Uncomment to print the current service endpoint.
19+
#define PRINT_ENDPOINT
20+
1821
using IBM.Watson.DeveloperCloud.Logging;
1922
using System.Collections;
2023
using UnityEngine;
@@ -26,10 +29,17 @@ namespace IBM.Watson.DeveloperCloud.UnitTests
2629
/// </summary>
2730
public abstract class UnitTest
2831
{
32+
/// <summary>
33+
/// Which credential should the tests use. Default is 0.
34+
/// </summary>
35+
public int TestCredentialIndex = 0;
36+
2937
public bool TestFailed { get; set; }
3038

3139
public abstract IEnumerator RunTest();
3240

41+
protected string _url;
42+
3343
/// <summary>
3444
/// Utility function that fails this test if false.
3545
/// </summary>
@@ -44,6 +54,9 @@ public void Test(bool condition)
4454
else
4555
{
4656
Log.Status("UnitTest", "UnitTest {0} has passed.", GetType().Name);
57+
#if PRINT_ENDPOINT
58+
Log.Status("UnitTest", "endpoint: {0}", _url);
59+
#endif
4760
}
4861
}
4962

ThirdParty/WebSocketSharp/websocket-sharp.csproj.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)