Exemplo n.º 1
0
        static void Main(string[] args)
        {
            UnityContainer container = new UnityContainer();
            container.RegisterInstance<IServiceLocator>(new UnityServiceLocatorAdapter(container));

            container.RegisterType<IModuleInitializer, ModuleInitializer>();

            TextLogger logger = new TextLogger();
            container.RegisterInstance<ILoggerFacade>(logger);

            IEventAggregator eventAggregator = new EventAggregator();
            container.RegisterInstance<IEventAggregator>(eventAggregator);

            ModuleCatalog catalog = new ModuleCatalog();
            //catalog.AddModule(typeof(RFID.RFIDModule));
            catalog.AddModule(typeof(BookInformation.BookInformationModule));
            catalog.AddModule(typeof(BookLocation.BookLocationModule));
            container.RegisterInstance<IModuleCatalog>(catalog);

            container.RegisterType<IModuleManager, ModuleManager>();
            IModuleManager manager = container.Resolve<IModuleManager>();
            manager.Run();
            //测试RFID服务模块的功能
            //RFIDUnitTest.testRFID(container);
            /******/
            //测试串口服务的功能
            //SerialUnitTest.testSerial(container);
            //测试数据库功能
            DatabaseUnitTest.testAllDatabase(container);
        }
Exemplo n.º 2
0
        public void ShouldDisposeWriterOnDispose()
        {
            MockWriter writer = new MockWriter();
            IDisposable logger = new TextLogger(writer);

            Assert.IsFalse(writer.DisposeCalled);
            logger.Dispose();
            Assert.IsTrue(writer.DisposeCalled);
        }
Exemplo n.º 3
0
        public void ShouldWriteToTextWriter()
        {
            TextWriter writer = new StringWriter();
            ILoggerFacade logger = new TextLogger(writer);

            logger.Log("Test", Category.Debug, Priority.Low);
            StringAssert.Contains(writer.ToString(), "Test");
            StringAssert.Contains(writer.ToString(), "DEBUG");
            StringAssert.Contains(writer.ToString(), "Low");
        }
Exemplo n.º 4
0
 public void NullTextWriterThrows()
 {
     ILoggerFacade logger = new TextLogger(null);
 }