public void ProxyIsCreated() { var generator = new PlugInProxyTypeGenerator(); var proxy = generator.GenerateProxy <IExamplePlugIn>(new PlugInManager(null, new NullLoggerFactory(), null)); Assert.That(proxy, Is.Not.Null); }
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(); }
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(); }
public void ErrorForInterfaceWithUnsupportedMethodSignature() { var generator = new PlugInProxyTypeGenerator(); Assert.Throws <ArgumentException>(() => generator.GenerateProxy <IUnsupportedPlugIn>(new PlugInManager(null, new NullLoggerFactory(), null))); }
public void ErrorForInterfaceWithoutAttribute() { var generator = new PlugInProxyTypeGenerator(); Assert.Throws <ArgumentException>(() => generator.GenerateProxy <ICloneable>(new PlugInManager(null, new NullLoggerFactory(), null))); }
public void ErrorForClasses() { var generator = new PlugInProxyTypeGenerator(); Assert.Throws <ArgumentException>(() => generator.GenerateProxy <ExamplePlugIn>(new PlugInManager(null, new NullLoggerFactory(), null))); }