public async Task ShouldThrowExceptionOnRenameEntityTestWhenExistsEntityWithSameName() { using (var client = new LuisProgClient(SubscriptionKey, Region)) { var entity = await client.GetEntityByNameAsync(EntityName, appId, appVersion); var entityChanged = await client.GetEntityByNameAsync(EntityNameChanged, appId, appVersion); string entityChangedId = null; if (entity == null) { await client.AddEntityAsync(EntityName, appId, appVersion); entity = await client.GetEntityByNameAsync(EntityName, appId, appVersion); } if (entityChanged == null) { entityChangedId = await client.AddEntityAsync(EntityNameChanged, appId, appVersion); } var ex = await Assert.ThrowsExceptionAsync <Exception>(() => client.RenameEntityAsync(entity.Id, EntityNameChanged, appId, appVersion)); Assert.AreEqual(ex.Message, "BadArgument - The models: { EntityTestChanged } already exist in the specified application version."); } }
public async Task ShouldThrowExceptionOnRenameEntityTestWhenExistsEntityWithSameName() { var client = new LuisProgClient(SUBSCRIPTION_KEY, LOCATION); var entity = await client.GetEntityByNameAsync("EntityTest", _appId, "1.0"); var entityChanged = await client.GetEntityByNameAsync("EntityTestChanged", _appId, "1.0"); string entityChangedId = null; if (entity == null) { await client.AddEntityAsync("EntityTest", _appId, "1.0"); entity = await client.GetEntityByNameAsync("EntityTest", _appId, "1.0"); } if (entityChanged == null) { entityChangedId = await client.AddEntityAsync("EntityTestChanged", _appId, "1.0"); } var ex = await Assert.ThrowsExceptionAsync <Exception>(() => client.RenameEntityAsync(entity.Id, "EntityTestChanged", _appId, "1.0")); Assert.AreEqual(ex.Message, "The application already contains an entity extractor with the same name"); }
public async Task ShouldAddLabelledExample() { using (var client = new LuisProgClient(SubscriptionKey, Region)) { // Add simple entity name if not already exists if (await client.GetEntityByNameAsync("name", appId, appVersion) == null) { await client.AddEntityAsync("name", appId, appVersion); } if (await client.GetIntentByNameAsync(IntentName, appId, appVersion) == null) { await client.AddIntentAsync(IntentName, appId, appVersion); } var labeledExample = new Example() { Text = "Who is Test User!", IntentName = IntentName, EntityLabels = new List <EntityLabel> { new EntityLabel { EntityName = "name", StartCharIndex = 7, EndCharIndex = 15 } } }; var utterance = await client.AddExampleAsync(appId, appVersion, labeledExample); Assert.IsNotNull(utterance); } }
public async Task ShouldRenameEntityTest() { using (var client = new LuisProgClient(SubscriptionKey, Region)) { var entity = await client.GetEntityByNameAsync(EntityName, appId, appVersion); var entityChanged = await client.GetEntityByNameAsync(EntityNameChanged, appId, appVersion); if (entity == null) { await client.AddEntityAsync(EntityName, appId, appVersion); entity = await client.GetEntityByNameAsync(EntityName, appId, appVersion); } if (entityChanged != null) { await client.DeleteEntityAsync(entityChanged.Id, appId, appVersion); } await client.RenameEntityAsync(entity.Id, EntityNameChanged, appId, appVersion); entity = await client.GetEntityByIdAsync(entity.Id, appId, appVersion); Assert.AreEqual(EntityNameChanged, entity.Name); } }
public async Task ShouldRenameEntityTest() { var client = new LuisProgClient(SUBSCRIPTION_KEY, LOCATION); var entity = await client.GetEntityByNameAsync("EntityTest", _appId, "1.0"); var entityChanged = await client.GetEntityByNameAsync("EntityTestChanged", _appId, "1.0"); if (entity == null) { await client.AddEntityAsync("EntityTest", _appId, "1.0"); entity = await client.GetEntityByNameAsync("EntityTest", _appId, "1.0"); } if (entityChanged != null) { await client.DeleteEntityAsync(entityChanged.Id, _appId, "1.0"); } await client.RenameEntityAsync(entity.Id, "EntityTestChanged", _appId, "1.0"); entity = await client.GetEntityByIdAsync(entity.Id, _appId, "1.0"); Assert.AreEqual("EntityTestChanged", entity.Name); }
public async Task ShouldThrowExceptionOnEntityNewEntityTestWhenAlreadyExists() { using (var client = new LuisProgClient(SubscriptionKey, Region)) { var entityTest = await client.GetEntityByNameAsync(EntityName, appId, appVersion); if (entityTest == null) { await client.AddEntityAsync(EntityName, appId, appVersion); } var ex = await Assert.ThrowsExceptionAsync <Exception>(() => client.AddEntityAsync(EntityName, appId, appVersion)); Assert.AreEqual(ex.Message, "BadArgument - The models: { EntityTest } already exist in the specified application version."); } }
public async Task ShouldThrowExceptionOnEntityNewEntityTestWhenAlreadyExists() { var client = new LuisProgClient(SUBSCRIPTION_KEY, LOCATION); var ex = await Assert.ThrowsExceptionAsync <Exception>(() => client.AddEntityAsync("EntityTest", _appId, "1.0")); Assert.AreEqual(ex.Message, "An entity extractor with the name EntityTest already exists in the application"); }
public async Task ShoulAddBatchLbeledExample() { using (var client = new LuisProgClient(SubscriptionKey, Region)) { // Add simple entity name if not already exists if (await client.GetEntityByNameAsync("name", appId, appVersion) == null) { await client.AddEntityAsync("name", appId, appVersion); } // Add simple intent name if not already exists if (await client.GetIntentByNameAsync(IntentName, appId, appVersion) == null) { await client.AddIntentAsync(IntentName, appId, appVersion); } List <Example> examples = new List <Example>(); examples.Add(new Example() { Text = "Who is Bill?", IntentName = IntentName, EntityLabels = new List <EntityLabel> { new EntityLabel { EntityName = "name", StartCharIndex = 7, EndCharIndex = 10 } } }); examples.Add(new Example() { Text = "Who is Christopher?", IntentName = IntentName, EntityLabels = new List <EntityLabel> { new EntityLabel { EntityName = "name", StartCharIndex = 7, EndCharIndex = 17 } } }); var addExamples = await client.AddBatchExampleAsync(appId, appVersion, examples.ToArray()); Assert.AreEqual <bool>(false, addExamples[0].HasError); Assert.AreEqual <bool>(false, addExamples[1].HasError); } }
public async Task ShouldGetEntityByName() { var client = new LuisProgClient(SUBSCRIPTION_KEY, LOCATION); if (await client.GetEntityByNameAsync("EntityTest", _appId, "1.0") == null) { await client.AddEntityAsync("EntityTest", _appId, "1.0"); } var entity = await client.GetEntityByNameAsync("EntityTest", _appId, "1.0"); Assert.IsNotNull(entity); }
public async Task ShouldGetEntityByName() { using (var client = new LuisProgClient(SubscriptionKey, Region)) { if (await client.GetEntityByNameAsync(EntityName, appId, appVersion) == null) { await client.AddEntityAsync(EntityName, appId, appVersion); } var entity = await client.GetEntityByNameAsync(EntityName, appId, appVersion); Assert.IsNotNull(entity); } }
public async Task ShouldAddNewEntityTest() { var client = new LuisProgClient(SUBSCRIPTION_KEY, LOCATION); var entityTest = await client.GetEntityByNameAsync("EntityTest", _appId, "1.0"); if (entityTest != null) { await client.DeleteEntityAsync(entityTest.Id, _appId, "1.0"); } var newId = await client.AddEntityAsync("EntityTest", _appId, "1.0"); Assert.IsNotNull(newId); }
public async Task ShouldAddNewEntityTest() { using (var client = new LuisProgClient(SubscriptionKey, Region)) { var entityTest = await client.GetEntityByNameAsync(EntityName, appId, appVersion); if (entityTest != null) { await client.DeleteEntityAsync(entityTest.Id, appId, appVersion); } var newId = await client.AddEntityAsync(EntityName, appId, appVersion); Assert.IsNotNull(newId); } }
public async Task ShouldGetExistEntityById() { var client = new LuisProgClient(SUBSCRIPTION_KEY, LOCATION); var entities = await client.GetAllEntitiesAsync(_appId, "1.0"); if (entities.Count == 0) { await client.AddEntityAsync("EntityTest", _appId, "1.0"); entities = await client.GetAllEntitiesAsync(_appId, "1.0"); } var firstEntity = entities.FirstOrDefault(); var entity = await client.GetEntityByIdAsync(firstEntity.Id, _appId, "1.0"); Assert.AreEqual(firstEntity.Name, entity.Name); }
public async Task ShouldGetExistEntityById() { using (var client = new LuisProgClient(SubscriptionKey, Region)) { var entities = await client.GetAllEntitiesAsync(appId, appVersion); if (entities.Count == 0) { await client.AddEntityAsync(EntityName, appId, appVersion); entities = await client.GetAllEntitiesAsync(appId, appVersion); } var firstEntity = entities.FirstOrDefault(); var entity = await client.GetEntityByIdAsync(firstEntity.Id, appId, appVersion); Assert.AreEqual(firstEntity.Name, entity.Name); } }