Пример #1
0
        public void Setup()
        {
            _controller           = new Mock <IController>();
            _monitorableProcessor = new Mock <IProcessor>();
            _outputGateway        = new Mock <IOutputGateway <IMessage> >();
            _frequenceHelper      = new Mock <IFrequenceHelper>();
            _businfo           = new Mock <IBusInfo>();
            _processorEndpoit  = new Mock <IEndPoint>();
            _controllerEndpoit = new Mock <IEndPoint>();

            _businfo.Setup(x => x.Identification).Returns(new Identification());
            _processorEndpoit.Setup(x => x.Uri).Returns(new Uri("http://someUrl"));
            _controllerEndpoit.Setup(x => x.Uri).Returns(new Uri("http://someUrl"));

            _monitorableProcessor.Setup(x => x.Identification).Returns(new Identification());
            _monitorableProcessor.Setup(x => x.JoinedBusInfo).Returns(_businfo.Object);
            _monitorableProcessor.Setup(x => x.ReceiverEndPoint).Returns(_processorEndpoit.Object);

            _controller.Setup(x => x.ReceiverEndPoint).Returns(_controllerEndpoit.Object);
            _controller.SetupProperty(x => x.Processor, _monitorableProcessor.Object);

            _frequenceHelper.Setup(f => f.GetFrequence(It.IsAny <FrequenceLevel>())).Returns(60);

            MonitorFactory.Create(_frequenceHelper.Object);
        }
Пример #2
0
        protected override void BecauseOf()
        {
            _monitor = _sut.Create(SCardScope.System);

            // Give the monitor thread 1 seconds (until we fail this test)
            Thread.Sleep(TimeSpan.FromSeconds(1));
        }
Пример #3
0
        /// <summary>
        /// Creates the monitor factory.
        /// </summary>
        /// <returns></returns>
        private MonitorConfigurator CreateMonitorFactory()
        {
            var frequenceHelper = new FrequenceHelper();

            if (_monitorConfig.FrequenceLevel.Highest.HasValue)
            {
                frequenceHelper.ChangeFrequence(FrequenceLevel.Highest, _monitorConfig.FrequenceLevel.Highest.Value);
            }
            if (_monitorConfig.FrequenceLevel.High.HasValue)
            {
                frequenceHelper.ChangeFrequence(FrequenceLevel.High, _monitorConfig.FrequenceLevel.High.Value);
            }
            if (_monitorConfig.FrequenceLevel.Normal.HasValue)
            {
                frequenceHelper.ChangeFrequence(FrequenceLevel.Normal, _monitorConfig.FrequenceLevel.Normal.Value);
            }
            if (_monitorConfig.FrequenceLevel.Low.HasValue)
            {
                frequenceHelper.ChangeFrequence(FrequenceLevel.Low, _monitorConfig.FrequenceLevel.Low.Value);
            }
            if (_monitorConfig.FrequenceLevel.Lowest.HasValue)
            {
                frequenceHelper.ChangeFrequence(FrequenceLevel.Lowest, _monitorConfig.FrequenceLevel.Lowest.Value);
            }
            MonitorFactory.Create(frequenceHelper);

            return(this);
        }
Пример #4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            string logFilename = "kklog_.txt";

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.File(logFilename, outputTemplate: "{Timestamp:yyyy-MM-dd,HH:mm:ss},{Message:lj}{NewLine}{Exception}", restrictedToMinimumLevel: LogEventLevel.Information, rollingInterval: RollingInterval.Day)
                         .WriteTo.File("kkdebug.log")
                         .WriteTo.Trace()
                         .CreateLogger();

            MainForm mf          = new MainForm();
            var      readerNames = GetReaderNames();

            Log.Information("READERLIST," + string.Join(",", readerNames));
            List <string> monitoredReaders = new List <String>();
            string        r0 = ConfigurationManager.AppSettings["exitreadername"];

            if (Array.IndexOf(readerNames, r0) < 0)
            {
                Log.Information("ERROR,exit reader not found " + r0);
            }
            else
            {
                monitoredReaders.Add(r0);
            }
            string r1 = ConfigurationManager.AppSettings["entrancereadername"];

            if (Array.IndexOf(readerNames, r1) < 0)
            {
                Log.Information("ERROR,entrance reader not found " + r1);
            }
            else
            {
                monitoredReaders.Add(r1);
            }



            if (monitoredReaders.Count > 0)
            {
                var monitorFactory = new MonitorFactory(_contextFactory);
                var monitor        = monitorFactory.Create(SCardScope.System);
                monitor.CardInserted     += (sender, args) => ProcessEvent(mf, args);
                monitor.MonitorException += MonitorException;

                monitor.Start(monitoredReaders.ToArray());
            }
            else
            {
                Log.Error("ERROR,There are currently useable readers installed. " + readerNames);
            }
            Log.Debug("KurtKilepteto Started");

            Application.Run(mf);
        }