Пример #1
0
        public void Login()
        {
            var auth = new TwitchAuthenticationDetails()
            {
                Username = Username,
                Channel  = Channel,
                Password = AuthToken.ToUnsecureString(),
            };

            try
            {
                var stream     = new NetworkStreamTcpAdapter("irc.chat.twitch.tv", 6667);
                var connection = new TwitchChannelConnection(stream, auth);
                var client     = new TwitchClient(connection);

                Save();

                IsBusy = true;
                client.Disconnected += DisplayLoginError;
                client.Connected    += () => {
                    IsBusy = false;
                    client.Disconnected -= DisplayLoginError;
                    (new ChatBotWindow(client)).Show();
                    Close();
                };
                client.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public void TwitchChannelConnectionThrowsWithInvalidAuthenticationFormat(string name, string pass, string channel)
        {
            TwitchAuthenticationDetails invalidAuth = new TwitchAuthenticationDetails()
            {
                Username = name,
                Password = pass,
                Channel  = channel
            };

            Assert.That(() => new TwitchChannelConnection(stream, invalidAuth), Throws.ArgumentException);
        }
        public void InitializeTest()
        {
            auth = new TwitchAuthenticationDetails()
            {
                Username = "******",
                Password = "******",
                Channel  = "#test",
            };

            memoryStream = new MemoryStream();
            stream       = new NetworkStreamMock(memoryStream);
        }
        public void TwitchChannelConnectionFixesChannelName(string channel, string expectedChannel)
        {
            TwitchAuthenticationDetails validAuth = new TwitchAuthenticationDetails()
            {
                Username = "******",
                Password = "******",
                Channel  = channel
            };

            using (var connection = new TwitchChannelConnection(stream, validAuth))
                Assert.That(connection.Channel, Is.EqualTo(expectedChannel));
        }
        public void TwitchChannelConnectionThrowsNothingWithValidData(string name, string pass, string channel)
        {
            TwitchAuthenticationDetails validAuth = new TwitchAuthenticationDetails()
            {
                Username = name,
                Password = pass,
                Channel  = channel
            };

            Assert.That(() => {
                var c = new TwitchChannelConnection(stream, validAuth);
                c.Close();
            }, Throws.Nothing);
        }