Exemple #1
0
        public static async Task DoesNotCreateIfBotExists()
        {
            var botName    = Guid.NewGuid().ToString();
            var mockClient = new MockLexClient();

            mockClient.Set(new GetBotsResponse
            {
                Bots = new List <BotMetadata>
                {
                    new BotMetadata
                    {
                        Name = botName,
                    },
                },
            });

            using (var lex = new LexNLUService(botName, string.Empty, new LexSettings(), mockClient))
            {
                await lex.TrainAsync(Array.Empty <LabeledUtterance>()).ConfigureAwait(false);

                // There are at most two put bot requests, the first to create the bot, the second to build
                // If the bot exists, only the second put bot to build should occur.
                mockClient.Requests.OfType <PutBotRequest>().Count().Should().Be(1);
                mockClient.Requests.OfType <PutBotRequest>().First().ProcessBehavior.Should().Be(ProcessBehavior.BUILD);
            }
        }
Exemple #2
0
        public static async Task DoesNotPublishIfAliasExists()
        {
            var botAlias   = Guid.NewGuid().ToString();
            var mockClient = new MockLexClient();

            mockClient.Set(new GetBotAliasesResponse
            {
                BotAliases = new List <BotAliasMetadata>
                {
                    new BotAliasMetadata
                    {
                        Name = botAlias,
                    },
                },
            });

            using (var lex = new LexNLUService(string.Empty, botAlias, new LexSettings(), mockClient))
            {
                await lex.TrainAsync(Array.Empty <LabeledUtterance>()).ConfigureAwait(false);

                // If the bot alias exists, the 'PutBotAlias' request should not occur
                mockClient.Requests.OfType <PutBotAliasRequest>().Count().Should().Be(0);
            }
        }