public void ImplementAbstractClass_Ok()
        {
            // Arrange
            var mockDelegateBuilder = Substitute.For <IDelegateTypeBuilder>();

            mockDelegateBuilder.CreateDelegateType(Arg.Any <MethodInfo>(), Arg.Any <ModuleBuilder>()).Returns(typeof(Func <string>));
            var mockLibrary = Substitute.For <ILibrary>();
            var lib         = new LibraryInterfaceMapper(mockDelegateBuilder, new DefaultConstructorBuilder(null), new MockMethodWrapper());


            // Act
            var result = lib.Implement <AbstractFoo>(mockLibrary);

            // Assert
            mockLibrary.Received(1).GetProcedure <Func <string> >("Foo");
        }
        public void ImplementInterface_Ok()
        {
            // Arrange
            var mockDelegateBuilder = Substitute.For <IDelegateTypeBuilder>();

            mockDelegateBuilder.CreateDelegateType(Arg.Any <MethodInfo>(), Arg.Any <ModuleBuilder>()).Returns(typeof(Func <string>));
            var mockLibrary = new MockLibrary();
            var lib         = new LibraryInterfaceMapper(mockDelegateBuilder, new DefaultConstructorBuilder(null), new MockMethodWrapper());


            // Act
            var result = lib.Implement <IDoFoo2>(mockLibrary);

            // Assert
            Assert.IsTrue(mockLibrary.Received);
        }
        public void ImplementInterface_MissingMethod_ThrowsEntryPointNotFoundException()
        {
            // Arrange
            var mockDelegateBuilder = Substitute.For <IDelegateTypeBuilder>();

            mockDelegateBuilder.CreateDelegateType(Arg.Any <MethodInfo>(), Arg.Any <ModuleBuilder>()).Returns(typeof(Func <string>));
            var mockLibrary = Substitute.For <ILibrary>();

            mockLibrary.Name.Returns("FooLib");
            mockLibrary.GetProcedure <Func <string> >(Arg.Any <string>()).Returns((Func <string>)null);

            var lib = new LibraryInterfaceMapper(mockDelegateBuilder, new DefaultConstructorBuilder(null), new MockMethodWrapper());

            // Act
            // Assert
            var ex = Assert.Throws <MissingEntryPointException>(() => lib.Implement <IDoFoo>(mockLibrary));

            Assert.AreEqual("DoFoo", ex.EntryPoint);
            Assert.AreEqual("FooLib", ex.LibraryName);
        }