Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            int    serverPort = 5500;
            int    wolfCounut = 1;
            string serverIp   = "127.0.0.1";

            if (args.Length > 0)
            {
                serverIp = args[0];
            }


            Console.WriteLine("Press 1 - server[s] ");
            Console.WriteLine("Press 2 - one clietn");
            Console.WriteLine("Press 3 - server and one serverBot");
            Console.WriteLine("Press any other - Clietn[s]");
            var input = Console.ReadKey(true).Key;

            Console.Clear();

            if (input == ConsoleKey.D1)
            {
                _testServer   = new BotTestServer(serverPort, wolfCounut);
                Console.Title = "Server[s]";
            }
            else if (input == ConsoleKey.D2)
            {
                _testClients  = new TestBotClient(serverPort, serverIp, wolfCounut, 1);
                Console.Title = "Client";
            }
            else if (input == ConsoleKey.D3)
            {
                _testServer   = new BotTestServer(serverPort, wolfCounut);
                _testClients  = new TestBotClient(serverPort, serverIp, wolfCounut, 1);
                Console.Title = "Server[s] and Client[s]";
            }
            else
            {
                _testClients  = new TestBotClient(serverPort, serverIp, wolfCounut, 1);
                Console.Title = "Clients[s]";
            }

            Console.WriteLine("Server ip= " + serverIp);


            Thread loop = new Thread(Loop);

            loop.IsBackground = true;
            loop.Start();

            Console.WriteLine("Press key to exit");
            Console.ReadKey(true);
            loop.Abort();
            Stop();
            Console.WriteLine("Exit");
            Console.ReadKey(true);
        }
Ejemplo n.º 2
0
        public async Task Host_WhenRequested_ShouldRedirectToSkill()
        {
            var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(2));

            var testBot = new TestBotClient(new EnvironmentBotTestConfiguration());

            await testBot.StartConversation(cancellationTokenSource.Token);

            await testBot.SendMessageAsync("Hi", cancellationTokenSource.Token);

            await testBot.AssertReplyAsync("Me no nothin", cancellationTokenSource.Token);

            await testBot.SendMessageAsync("skill", cancellationTokenSource.Token);

            await testBot.AssertReplyAsync("Echo: skill", cancellationTokenSource.Token);
        }
Ejemplo n.º 3
0
        public async Task Host_WhenSkillEnds_HostReceivesEndOfConversation()
        {
            var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(2));

            var testBot = new TestBotClient(new EnvironmentBotTestConfiguration());

            await testBot.StartConversation(cancellationTokenSource.Token);

            await testBot.SendMessageAsync("Hi", cancellationTokenSource.Token);

            await testBot.AssertReplyAsync("Me no nothin", cancellationTokenSource.Token);

            await testBot.SendMessageAsync("skill", cancellationTokenSource.Token);

            await testBot.AssertReplyAsync("Echo: skill", cancellationTokenSource.Token);

            await testBot.SendMessageAsync("end", cancellationTokenSource.Token);

            await testBot.AssertReplyAsync("Received endOfConversation", cancellationTokenSource.Token);
        }
Ejemplo n.º 4
0
        public async Task Skill_OAuthCard_SignInSuccessful()
        {
            // If the test takes more than one minute, declare failure.
            var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(2));

            var testBot = new TestBotClient(new EnvironmentBotTestConfiguration());

            await testBot.StartConversation(cancellationTokenSource.Token);

            await testBot.SendMessageAsync("Hello", cancellationTokenSource.Token);

            await testBot.AssertReplyAsync("Me no nothin", cancellationTokenSource.Token);

            await testBot.SendMessageAsync("skill", cancellationTokenSource.Token);

            await testBot.AssertReplyAsync("Echo: skill", cancellationTokenSource.Token);

            await testBot.SendMessageAsync("auth", cancellationTokenSource.Token);

            var messages = await testBot.ReadBotMessagesAsync(cancellationTokenSource.Token);

            var activities = messages.ToList();

            Console.WriteLine("Enumerating activities:");
            foreach (var a in activities)
            {
                Console.WriteLine($"Type={a.Type}; Text={a.Text}; Code={a.Code}; Attachments count={a.Attachments.Count}");
            }

            var error = activities.FirstOrDefault(
                m => m.Type == ActivityTypes.EndOfConversation && m.Code == "SkillError");

            if (error != null)
            {
                Assert.Fail(error.Text);
            }

            await testBot.SignInAndVerifyOAuthAsync(activities.FirstOrDefault(m => m.Attachments != null && m.Attachments.Any()), cancellationTokenSource.Token);
        }