public static async Task DoesNotOverwriteTemplateIntents()
        {
            var role        = Guid.NewGuid().ToString();
            var intentName  = Guid.NewGuid().ToString();
            var appTemplate = new LuisApp
            {
                ClosedLists = new List <ClosedList>(),
                Entities    = new List <HierarchicalModel>(),
                Intents     = new List <HierarchicalModel>
                {
                    new HierarchicalModel
                    {
                        Name  = intentName,
                        Roles = new List <string> {
                            role
                        },
                    },
                },
                ModelFeatures    = new List <JSONModelFeature>(),
                PrebuiltEntities = new List <PrebuiltEntity>(),
            };

            var builder = new LuisNLUTrainClientBuilder();

            builder.LuisTemplate = appTemplate;
            using (var luis = builder.Build())
            {
                var utterance = new Core.LabeledUtterance(null, intentName, null);
                await luis.TrainAsync(new[] { utterance }).ConfigureAwait(false);

                // Ensure LUIS app intent still has role
                var importRequest = builder.MockLuisTrainClient.Invocations.FirstOrDefault(request => request.Method.Name == nameof(ILuisTrainClient.ImportVersionAsync));
                importRequest.Should().NotBeNull();
                var luisApp = importRequest.Arguments[2].As <LuisApp>();
                luisApp.Intents.Should().Contain(intent => intent.Name == intentName);
                luisApp.Intents.First(intent => intent.Name == intentName).Roles.Count.Should().Be(1);
                luisApp.Intents.First(intent => intent.Name == intentName).Roles.First().Should().Be(role);
            }
        }
        public static async Task AddsRoleToEntities()
        {
            var text = Guid.NewGuid().ToString();

            var builder = new LuisNLUTrainClientBuilder();

            builder.LuisTemplate = new LuisApp
            {
                PrebuiltEntities = new[]
                {
                    new PrebuiltEntity
                    {
                        Name  = "number",
                        Roles = new[] { "count" },
                    }
                },
            };

            using (var luis = builder.Build())
            {
                var entity1   = new Entity("number", null, text, 0);
                var entity2   = new Entity("count", null, text, 0);
                var utterance = new Core.LabeledUtterance(text, string.Empty, new[] { entity1, entity2 });
                await luis.TrainAsync(new[] { utterance }).ConfigureAwait(false);

                // Ensure LUIS app intent still has role
                var importRequest = builder.MockLuisTrainClient.Invocations.FirstOrDefault(request => request.Method.Name == nameof(ILuisTrainClient.ImportVersionAsync));
                importRequest.Should().NotBeNull();
                var luisApp = importRequest.Arguments[2].As <LuisApp>();
                luisApp.Utterances.Should().Contain(u => u.Text == text);
                luisApp.Utterances.First(u => u.Text == text).Entities.Count().Should().Be(2);
                luisApp.Utterances.First(u => u.Text == text).Entities[0].Entity.Should().Be("number");
                luisApp.Utterances.First(u => u.Text == text).Entities[1].Entity.Should().Be("number");
                luisApp.Utterances.First(u => u.Text == text).Entities.OfType <JSONEntityWithRole>().Single().Role.Should().Be("count");
            }
        }