Пример #1
0
        public void On()
        {
            var log = LogManager.GetLogger(Global.CallerName());

            log.Info("Start");

            var emitter = new Emitter();
            var calls   = new List <object>();

            var listener1 = new TestListener1(calls);

            emitter.On("foo", listener1);

            var listener2 = new TestListener2(calls);

            emitter.On("foo", listener2);

            emitter.Emit("foo", 1);
            emitter.Emit("bar", 1);
            emitter.Emit("foo", 2);

            var expected = new Object[] { "one", 1, "two", 1, "one", 2, "two", 2 };

            CollectionAssert.AreEqual(expected, calls.ToArray());
        }
Пример #2
0
        public void On()
        {
            LogManager.SetupLogManager();
            var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());

            log.Info("Start");

            var emitter = new Emitter();
            var calls   = new List <object>();

            var listener1 = new TestListener1(calls);

            emitter.On("foo", listener1);

            var listener2 = new TestListener2(calls);

            emitter.On("foo", listener2);

            emitter.Emit("foo", 1);
            emitter.Emit("bar", 1);
            emitter.Emit("foo", 2);

            var expected = new Object[] { "one", 1, "two", 1, "one", 2, "two", 2 };

            Assert.Equal(expected, calls.ToArray());
        }
        public void Once()
        {
            var emitter = new Emitter();
            var calls   = new List <object>();

            var listener1 = new TestListener1(calls);

            emitter.Once("foo", listener1);

            emitter.Emit("foo", 1);
            emitter.Emit("foo", 2);
            emitter.Emit("foo", 3);
            emitter.Emit("bar", 1);

            var expected = new Object[] { "one", 1 };

            Assert.Equal(expected, calls.ToArray());
        }
        public void Once()
        {
            var log = LogManager.GetLogger(Global.CallerName());
            log.Info("Start");

            var emitter = new Emitter();
            var calls = new List<object>();

            var listener1 = new TestListener1(calls);
            emitter.Once("foo", listener1);

            emitter.Emit("foo", 1);
            emitter.Emit("foo", 2);
            emitter.Emit("foo", 3);
            emitter.Emit("bar", 1);

            var expected = new Object[] {"one", 1};
            CollectionAssert.AreEqual(expected, calls.ToArray());
        }
Пример #5
0
        public void Once()
        {
            LogManager.SetupLogManager();
            var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod());
            log.Info("Start");

            var emitter = new Emitter();
            var calls = new List<object>();

            var listener1 = new TestListener1(calls);
            emitter.Once("foo", listener1);

            emitter.Emit("foo", 1);
            emitter.Emit("foo", 2);
            emitter.Emit("foo", 3);
            emitter.Emit("bar", 1);

            var expected = new Object[] {"one", 1};
            Assert.Equal(expected, calls.ToArray());
        }