Esempio n. 1
0
        public void StartShouldThrowIfDisposed()
        {
            IdentServer server = new IdentServer(_userName);

            server.Dispose();
            server.Start();
        }
Esempio n. 2
0
 private void StopIdentServer( )
 {
     if (0 == Interlocked.Decrement(ref _identServerUseCount))
     {
         _identServer.Stop( );
         _identServer = null;
     }
 }
Esempio n. 3
0
 private void StartIdentServer( )
 {
     if (1 == Interlocked.Increment(ref _identServerUseCount))
     {
         _identServer = new IdentServer( );
         _identServer.Start( );
     }
 }
Esempio n. 4
0
        public void DisposeShouldAllowMultipleCalls()
        {
            IdentServer server = new IdentServer(_userName);

            server.Dispose();
            server.Dispose();
            server.Dispose();
        }
Esempio n. 5
0
        public void Stop_DoNotDisposeListener()
        {
            IdentServer.UserNameNeeded += (s, e) => e.UserName = "******";

            var client   = new TestTcpWrapper();
            var listener = new TestTcpListenerWrapper();

            IdentServer.Start(listener);
            IdentServer.Stop(false);
            Assert.IsFalse(listener.Disposed);
        }
Esempio n. 6
0
        public void Stop_DisposeListener()
        {
            IdentServer.UserNameNeeded += (s, e) => e.UserName = "******";

            var client   = new TestTcpWrapper();
            var listener = new TestTcpListenerWrapper();

            IdentServer.Start(listener);
            IdentServer.Stop();
            listener.AddClient(client);
            client.ReceiveLine("0,0");
            Assert.AreEqual(0, client.LinesSent.Count);
            Assert.IsTrue(listener.Disposed);
        }
Esempio n. 7
0
        private void Run(string[] args)
        {
#if DEBUG
            Debug.Listeners.Add(new CustomTraceListener( ));
#endif

            var ports = new Collection <int>( );
            foreach (var arg in args[1].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                if ('+' == arg[0])
                {
                    IntHelper.TryParse(arg.Substring(1), _ => ports.Add(-_));
                }
                else
                {
                    IntHelper.TryParse(arg, ports.Add);
                }
            }

            Console.CancelKeyPress += ConsoleCancelKeyPress;

            _identServer = new IdentServer( );
            _identServer.Start( );

            _serverConnector = new ServerConnector(new ConnectionConfiguration {
                NickName         = "ZiveIrcTest",
                UserName         = "******",
                RealName         = "Testing instance of ZiveIrc. Contact: IceKarma",
                NickServPassword = "******",
                ServerHostName   = args[0],
                Ports            = ports,
            });

            _serverConnector.ConnectionEstablished    += ConnectionEstablished;
            _serverConnector.ConnectionAttemptStarted += ConnectionAttemptStarted;
            _serverConnector.ConnectionAttemptFailed  += ConnectionAttemptFailed;
            _serverConnector.ConnectionFailed         += ConnectionFailed;

            Console.WriteLine("Starting connection attempt.");
            _serverConnector.BeginConnect( );

            _doneEvent.WaitOne( );
            _doneEvent.Dispose( );
            _doneEvent = null;
        }
Esempio n. 8
0
 private void InitIrc()
 {
     statusBox.Items.Clear();
     if (_ircClient == null)
     {
         _ircClient = new IrcClient();
         _ircClient.Connected += new EventHandler(_ircClient_Connected);
         _ircClient.Closed += new EventHandler(_ircClient_Closed);
         _ircClient.GotJoinChannel += new EventHandler<JoinLeaveEventArgs>(_ircClient_GotJoinChannel);
         _ircClient.GotNotice += new EventHandler<ChatMessageEventArgs>(_ircClient_GotNotice);
         _ircClient.GotMessage += new EventHandler<ChatMessageEventArgs>(_ircClient_GotMessage);
         _ircClient.GotIrcError += new EventHandler<IrcErrorEventArgs>(_ircClient_GotIrcError);
         _ircClient.GotMotdEnd += new EventHandler(_ircClient_GotMotdEnd);
         _ircClient.GotNameListReply += new EventHandler<NameListReplyEventArgs>(_ircClient_GotNameListReply);
         _ircClient.GotLeaveChannel += new EventHandler<JoinLeaveEventArgs>(_ircClient_GotLeaveChannel);
         _ircClient.GotUserKicked += new EventHandler<KickEventArgs>(_ircClient_GotUserKicked);
     }
     if (_identServer == null)
     {
         try
         {
             _identServer = new IdentServer()
             {
                 UserID = _ircNickname
             };
             _identServer.Start(113);
         }
         catch (Exception)
         {
             statusBox.Items.Add("Couldn't start the ident server, this might be because you are already running another client");
         }
     }
     if (_ircClient.IsConnected)
         return;
     try
     {
         enterChatButton.Enabled = false;
         statusBox.Items.Add("Connecting...");
         _ircClient.Connect("irc.rizon.net", 6697, new IrcClientConnectionOptions()
         {
             Ssl = true,
             SslHostname = "irc.rizon.net",
             SslCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateSSL)
         });
     }
     catch (Exception ex)
     {
         enterChatButton.Enabled = true;
         statusBox.Items.Add("Connect error: " + ex.Message);
     }
 }
Esempio n. 9
0
        public void IsRunningShouldInitializeFalse()
        {
            IdentServer server = new IdentServer(_userName);

            Assert.AreEqual(false, server.IsRunning);
        }
Esempio n. 10
0
        public void TimeoutShouldNotAcceptNegativeNumber()
        {
            IdentServer server = new IdentServer(_userName);

            server.Timeout = -500;
        }
Esempio n. 11
0
        public void TimeoutShouldInitializeAsDefault()
        {
            IdentServer server = new IdentServer(_userName);

            Assert.AreEqual(IdentServer.DEFAULTTIMEOUT, server.Timeout);
        }
Esempio n. 12
0
 public void ConstructorShouldNotAcceptWhitespaceName()
 {
     IdentServer server = new IdentServer("           ");
 }
Esempio n. 13
0
 public void ConstructorShouldNowAcceptEmptyName()
 {
     IdentServer server = new IdentServer(string.Empty);
 }
Esempio n. 14
0
 public void ConstructorShouldNotAcceptNullName()
 {
     IdentServer server = new IdentServer(null);
 }
Esempio n. 15
0
        public void IsIDisposable()
        {
            IdentServer server = new IdentServer(_userName);

            Assert.IsInstanceOfType(server, typeof(IDisposable));
        }