Ejemplo n.º 1
0
        public void InitWithProperties()
        {
            MockRepository mocks = new MockRepository();

            Log4NetLoggerFactoryAdapter.ILog4NetRuntime rt = (Log4NetLoggerFactoryAdapter.ILog4NetRuntime)mocks.StrictMock(typeof(Log4NetLoggerFactoryAdapter.ILog4NetRuntime));

            string configFileName = new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath;

            using (mocks.Ordered())
            {
                rt.XmlConfiguratorConfigure();
                rt.XmlConfiguratorConfigure(configFileName);
                rt.XmlConfiguratorConfigureAndWatch(configFileName);
                rt.BasicConfiguratorConfigure();
                Expect.Call(rt.GetLogger("testLogger")).Return(mocks.DynamicMock <log4net.ILog>());
            }
            mocks.ReplayAll();

            Log4NetLoggerFactoryAdapter a;
            NameValueCollection         props = new NameValueCollection();

            props["configType"] = "inLiNe";
            a = new TestLog4NetLoggerFactoryAdapter(props, rt);

            props["ConfigTYPE"] = "fiLe";
            props["CONFIGFILE"] = configFileName;
            a = new TestLog4NetLoggerFactoryAdapter(props, rt);

            props["ConfigTYPE"] = "fiLe-WATCH";
            props["CONFIGFILE"] = configFileName;
            a = new TestLog4NetLoggerFactoryAdapter(props, rt);

            props["ConfigTYPE"] = "external";
            a = new TestLog4NetLoggerFactoryAdapter(props, rt);

            props["ConfigTYPE"] = "any unknown";
            a = new TestLog4NetLoggerFactoryAdapter(props, rt);

            a.GetLogger("testLogger");

            mocks.VerifyAll();
        }
        public void InitWithProperties()
        {
            MockRepository mocks = new MockRepository();
            Log4NetLoggerFactoryAdapter.ILog4NetRuntime rt = mocks.StrictMock<Log4NetLoggerFactoryAdapter.ILog4NetRuntime>();

            string configFileName = new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath;

            using(mocks.Ordered())
            {
                rt.XmlConfiguratorConfigure();
                rt.XmlConfiguratorConfigure(configFileName);
                rt.XmlConfiguratorConfigureAndWatch(configFileName);
                rt.BasicConfiguratorConfigure();
                Expect.Call(rt.GetLogger("testLogger")).Return(mocks.DynamicMock<log4net.ILog>());
            }
            mocks.ReplayAll();

            Log4NetLoggerFactoryAdapter a;
            NameValueCollection props = new NameValueCollection();
            
            props["configType"] = "inLiNe";
            a = new TestLog4NetLoggerFactoryAdapter(props, rt);

            props["ConfigTYPE"] = "fiLe";
            props["CONFIGFILE"] = configFileName;
            a = new TestLog4NetLoggerFactoryAdapter(props, rt);

            props["ConfigTYPE"] = "fiLe-WATCH";
            props["CONFIGFILE"] = configFileName;
            a = new TestLog4NetLoggerFactoryAdapter(props, rt);

            props["ConfigTYPE"] = "external";
            a = new TestLog4NetLoggerFactoryAdapter(props, rt);

            props["ConfigTYPE"] = "any unknown";
            a = new TestLog4NetLoggerFactoryAdapter(props, rt);

            a.GetLogger("testLogger");

            mocks.VerifyAll();
        }