Пример #1
0
        public void ShouldWriteToTraceWriter()
        {
            var listener = new MockTraceListener();
            Trace.Listeners.Add(listener);

            var traceLogger = new TraceLogger();
            traceLogger.Log("Test debug message", Category.Debug, Priority.Low);

            Assert.AreEqual<string>("Test debug message", listener.LogMessage);

            Trace.Listeners.Remove(listener);
        }
Пример #2
0
        public void ShouldTraceErrorException()
        {
            var listener = new MockTraceListener();
            Trace.Listeners.Add(listener);

            var traceLogger = new TraceLogger();
            traceLogger.Log("Test exception message", Category.Exception, Priority.Low);

            Assert.AreEqual<string>("Test exception message", listener.ErrorMessage);

            Trace.Listeners.Remove(listener);
        }
Пример #3
0
        static void Main(string[] args)
        {
            var logger = new TraceLogger();

            var serviceHost = new AudienceHost(logger);
            serviceHost.Inititalize();
            serviceHost.Start("net.tcp://localhost:8003/PublishingService", "net.tcp://localhost:8004/SubscriptionService");

            var commandHandler = new CommandHandler();

            var cancellationToken = new CancellationTokenSource();

            Task.Factory.StartNew(
                () =>
                    {
                        var fmsEventListener = new TcpListener(IPAddress.Any, 8005);
                        fmsEventListener.Start();
                        while (!cancellationToken.Token.IsCancellationRequested)
                        {
                            Console.WriteLine("Waiting for connection");
                            var client = fmsEventListener.AcceptTcpClient();
                            Task.Factory.StartNew(() => ThreadProc(client, commandHandler), cancellationToken.Token);
                        }
                    },
                    cancellationToken.Token);

            Console.WriteLine("Waiting for command");

            var quit = false;
            while (!quit)
            {
                var input = Console.ReadLine();
                switch (input)
                {
                    case "q":
                        cancellationToken.Cancel();
                        quit = true;
                        break;
                    default:
                        lock (CommandHandler.LockObject)
                        {
                            commandHandler.SendCommand(input);
                        }

                        break;
                }

                Console.WriteLine("Waiting for command");
            }

            serviceHost.Stop();
        }