Ejemplo n.º 1
0
        public static async Task CleanupCallsLexActions()
        {
            var botName    = Guid.NewGuid().ToString();
            var botAlias   = Guid.NewGuid().ToString();
            var mockClient = new MockLexClient();

            using (var lex = new LexNLUService(botName, botAlias, new LexSettings(), mockClient))
            {
                await lex.CleanupAsync().ConfigureAwait(false);

                mockClient.Requests.OfType <DeleteBotAliasRequest>().Count().Should().Be(1);
                mockClient.Requests.OfType <DeleteBotAliasRequest>().First().Name.Should().Be(botAlias);
                mockClient.Requests.OfType <DeleteBotRequest>().Count().Should().Be(1);
                mockClient.Requests.OfType <DeleteBotRequest>().First().Name.Should().Be(botName);
            }
        }
Ejemplo n.º 2
0
        public static async Task CleanupSucceedsWithNotFound()
        {
            var botName    = Guid.NewGuid().ToString();
            var botAlias   = Guid.NewGuid().ToString();
            var mockClient = new MockLexClient();

            mockClient.OnRequest = request =>
            {
                if (request is DeleteBotAliasRequest || request is DeleteBotRequest)
                {
                    throw new Amazon.LexModelBuildingService.Model.NotFoundException(string.Empty);
                }
            };

            using (var lex = new LexNLUService(botName, botAlias, new LexSettings(), mockClient))
            {
                await lex.CleanupAsync().ConfigureAwait(false);

                mockClient.Requests.OfType <DeleteBotAliasRequest>().Count().Should().Be(1);
                mockClient.Requests.OfType <DeleteBotAliasRequest>().First().Name.Should().Be(botAlias);
                mockClient.Requests.OfType <DeleteBotRequest>().Count().Should().Be(1);
                mockClient.Requests.OfType <DeleteBotRequest>().First().Name.Should().Be(botName);
            }
        }