Beispiel #1
0
        public void Test_2OnConnect()
        {
            var testHandler1 = new TestHandler();
            var testHandler2 = new TestHandler();

            var eventManager = new ReflectionEventManager(null);

            eventManager.AddCommandHandler(testHandler1);
            eventManager.AddCommandHandler(testHandler2);
            eventManager.CallConnect(null);

            Assert.IsTrue(testHandler1.HasOnConnectBeenCalled);
            Assert.IsTrue(testHandler2.HasOnConnectBeenCalled);
        }
Beispiel #2
0
        public void Test_OnConnect()
        {
            var testHandler = new TestHandler();

            var eventManager = new ReflectionEventManager(null);

            eventManager.AddCommandHandler(testHandler);
            eventManager.CallConnect(null);

            Assert.IsTrue(testHandler.HasOnConnectBeenCalled);
            Assert.IsFalse(testHandler.HasBadOnConnectBeenCalled);
        }
Beispiel #3
0
        public void Test_BadOnCommand()
        {
            var mockSerializer = new Mock <ISerializer>();

            mockSerializer.Setup(m => m.Deserialize <string>(It.IsAny <byte[]>())).Returns("some data");

            var testHandler = new TestHandler();

            var eventManager = new ReflectionEventManager(mockSerializer.Object);

            eventManager.AddCommandHandler(testHandler);
            eventManager.CallCommand("String", new byte[] { 1, 2, 3 }, null);

            Assert.IsFalse(testHandler.HasBadOnCommandBeenCalled);
        }