-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Training Status Enum, AddBatchExamples, BatchExample Model, fla…
…g for Delete Intent Utterances, TrainAndGetCompletedStatus. Updated Publish Model
- Loading branch information
Prema Arya
committed
May 3, 2018
1 parent
2a22790
commit 106f172
Showing
19 changed files
with
1,147 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using Cognitive.LUIS.Programmatic.Models; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Cognitive.LUIS.Programmatic.Tests | ||
{ | ||
[TestClass] | ||
public class ExampleTests | ||
{ | ||
private const string SUBSCRIPTION_KEY = "{YourSubscriptionKey}"; | ||
private const Location LOCATION = Location.WestUS; | ||
private readonly string _appId; | ||
|
||
public ExampleTests() | ||
{ | ||
var client = new LuisProgClient(SUBSCRIPTION_KEY, LOCATION); | ||
var app = client.GetAppByNameAsync("SDKTest").Result; | ||
if (app != null) | ||
_appId = app.Id; | ||
else | ||
_appId = client.AddAppAsync("SDKTest", "Description test", "en-us", "SDKTest", string.Empty, "1.0").Result; | ||
} | ||
|
||
[TestMethod] | ||
public async Task ShouldAddExample() | ||
{ | ||
var client = new LuisProgClient(SUBSCRIPTION_KEY, LOCATION); | ||
string intentTestId = null; | ||
var intentTest = await client.GetIntentByNameAsync("IntentTest", _appId, "1.0"); | ||
if (intentTest != null) | ||
intentTestId = intentTest.Id; | ||
else | ||
intentTestId = await client.AddIntentAsync("IntentTest", _appId, "1.0"); | ||
|
||
var example = new Example | ||
{ | ||
Text = "Hello World!", | ||
IntentName = "IntentTest" | ||
}; | ||
|
||
var utterance = await client.AddExampleAsync(_appId, "1.0", example); | ||
|
||
Assert.IsNotNull(utterance); | ||
} | ||
|
||
[TestMethod] | ||
public async Task ShouldThrowExceptionOnAddExampleWhenIntentTestNotExists() | ||
{ | ||
var client = new LuisProgClient(SUBSCRIPTION_KEY, LOCATION); | ||
var intentTest = await client.GetIntentByNameAsync("IntentTest", _appId, "1.0"); | ||
if (intentTest != null) | ||
await client.DeleteIntentAsync(intentTest.Id, _appId, "1.0"); | ||
|
||
var example = new Example | ||
{ | ||
Text = "Hello World!", | ||
IntentName = "IntentTest" | ||
}; | ||
|
||
var ex = await Assert.ThrowsExceptionAsync<Exception>(() => | ||
client.AddExampleAsync(_appId, "1.0", example)); | ||
|
||
Assert.AreEqual(ex.Message, "The intent classifier IntentTest does not exist in the selected application"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.