public void RegisterForInterface_Implementation_SuccessfullyCreateWithNonDefaultConstructor()
        {
            var wrapType = OmniShim.RegisterForInterface <SuccessfulRegisterClass>("omnishim_test_core.ISimpleInterface");
            ISimpleInterface transform = (ISimpleInterface)Activator.CreateInstance(wrapType, "test2");

            Assert.AreEqual("test2", transform.DoThing("test1"));
        }
        public void RegisterForInterface_ReturnImplementationWithMirrorProto_SuccessfullyCallInterface()
        {
            OmniShim.RegisterMirrorProto <OtherData>("omnishim_test_core.SomeData");
            var             wrapType  = OmniShim.RegisterForInterface <ProtoMirrorClass>("omnishim_test_core.IProtoInterface");
            IProtoInterface transform = (IProtoInterface)Activator.CreateInstance(wrapType);

            Assert.AreEqual(new SomeData()
            {
                Name = "OtherDataOutput",
            }, transform.GetThing());
        }
        public void RegisterForInterface_ReturnImplementationWithProto_SuccessfullyCallInterface()
        {
            var             wrapType  = OmniShim.RegisterForInterface <ProtoRegisterClass>("omnishim_test_core.IProtoInterface");
            IProtoInterface transform = (IProtoInterface)Activator.CreateInstance(wrapType);

            Assert.AreEqual(new SomeData()
            {
                Name   = "SomeDataOutput",
                Number = 1.1,
                Fixed  = 2,
            }, transform.GetThing());
        }
        public void RegisterForInterface_ImplementationWithMirrorProto_SuccessfullyCallInterface()
        {
            OmniShim.RegisterMirrorProto <OtherData>("omnishim_test_core.SomeData");
            var             wrapType  = OmniShim.RegisterForInterface <ProtoMirrorClass>("omnishim_test_core.IProtoInterface");
            IProtoInterface transform = (IProtoInterface)Activator.CreateInstance(wrapType);

            Assert.AreEqual("test1", transform.DoThing(new SomeData()
            {
                Name   = "test1",
                Number = 5.3,
                Fixed  = 2,
            }));
        }
 public void RegisterForInterface_NoInterfaceImplementation_ThrowsException()
 {
     Assert.Throws(typeof(TypeLoadException), () => OmniShim.RegisterForInterface <FailedRegisterClass>("omnishim_test_core.ISimpleInterface"));
 }
Example #6
0
 public void Register_WithoutPrestart_ThrowsException()
 {
     Assert.Throws(typeof(Exception), () => OmniShim.RegisterForInterface <SuccessfulRegisterClass>());
 }