// Author: Gockner, Simon // Created: 2019-12-11 // Copyright(c) 2019 SimonG. All Rights Reserved. using LightweightIocContainer; using NUnit.Framework; namespace Test.LightweightIocContainer; [TestFixture] public class ActionExtensionTest { private interface IBar { void Throw(); } private interface IFoo : IBar { } private class Foo : IFoo { public void Throw() => throw new Exception(); } [Test] public void TestConvert() { Action barAction = bar => bar.Throw(); Action action = barAction.Convert(); Assert.Throws(() => action(new Foo())); } [Test] public void TestConvertActionNull() { Action barAction = null; Assert.That(barAction.Convert(), Is.Null); } }