コード例 #1
0
        public void ProxyIsCreated()
        {
            var generator = new PlugInProxyTypeGenerator();
            var proxy     = generator.GenerateProxy <IExamplePlugIn>(new PlugInManager(null, new NullLoggerFactory(), null));

            Assert.That(proxy, Is.Not.Null);
        }
コード例 #2
0
        public void CancelEventArgsAreRespected()
        {
            var generator = new PlugInProxyTypeGenerator();
            var proxy     = generator.GenerateProxy <IExamplePlugIn>(new PlugInManager(null, NullLoggerFactory.Instance, null));

            var player     = TestHelper.GetPlayer();
            var command    = "test";
            var args       = new MyEventArgs();
            var firstMock  = new Mock <IExamplePlugIn>();
            var secondMock = new Mock <IExamplePlugIn>();

            firstMock.Setup(p => p.DoStuff(player, command, args)).Callback(() => args.Cancel = true).Verifiable();
            proxy.AddPlugIn(firstMock.Object, true);
            proxy.AddPlugIn(secondMock.Object, true);

            (proxy as IExamplePlugIn)?.DoStuff(player, command, args);
            firstMock.VerifyAll();
            secondMock.VerifyAll();
            secondMock.VerifyNoOtherCalls();
        }
コード例 #3
0
        public void InactivePlugInsAreNotExecuted()
        {
            var generator = new PlugInProxyTypeGenerator();
            var proxy     = generator.GenerateProxy <IExamplePlugIn>(null);

            var player     = TestHelper.GetPlayer();
            var command    = "test";
            var args       = new MyEventArgs();
            var firstMock  = new Mock <IExamplePlugIn>();
            var secondMock = new Mock <IExamplePlugIn>();

            secondMock.Setup(p => p.DoStuff(player, command, args)).Verifiable();
            proxy.AddPlugIn(firstMock.Object, false);
            proxy.AddPlugIn(secondMock.Object, true);

            (proxy as IExamplePlugIn).DoStuff(player, command, args);

            firstMock.VerifyAll();
            firstMock.VerifyNoOtherCalls();
            secondMock.VerifyAll();
        }
コード例 #4
0
        public void ErrorForInterfaceWithUnsupportedMethodSignature()
        {
            var generator = new PlugInProxyTypeGenerator();

            Assert.Throws <ArgumentException>(() => generator.GenerateProxy <IUnsupportedPlugIn>(new PlugInManager(null, new NullLoggerFactory(), null)));
        }
コード例 #5
0
        public void ErrorForInterfaceWithoutAttribute()
        {
            var generator = new PlugInProxyTypeGenerator();

            Assert.Throws <ArgumentException>(() => generator.GenerateProxy <ICloneable>(new PlugInManager(null, new NullLoggerFactory(), null)));
        }
コード例 #6
0
        public void ErrorForClasses()
        {
            var generator = new PlugInProxyTypeGenerator();

            Assert.Throws <ArgumentException>(() => generator.GenerateProxy <ExamplePlugIn>(new PlugInManager(null, new NullLoggerFactory(), null)));
        }