示例#1
0
        public void ExecuteMethodOnCustomProxyThatIsAlsoInInterface_Throws_Ok()
        {
            ProxyFactory           factory  = new ProxyFactory(typeof(CustomProxy));
            Mock <IClientPipeline> pipeline = new Mock <IClientPipeline>();

            IDummyInterface proxy = factory.CreateProxy <IDummyInterface>(pipeline.Object);

            Assert.Throws <InvalidOperationException>(() => proxy.Execute(true));
        }
示例#2
0
        public void CreateProxy_EnsureIsCustomProxy()
        {
            ProxyFactory           factory  = new ProxyFactory(typeof(CustomProxy));
            Mock <IClientPipeline> pipeline = new Mock <IClientPipeline>();

            IDummyInterface proxy = factory.CreateProxy <IDummyInterface>(pipeline.Object);

            Assert.NotNull(proxy as CustomProxy);
        }
示例#3
0
        public void ExecuteMethodOnCustomProxyThatIsAlsoInInterface()
        {
            ProxyFactory           factory  = new ProxyFactory(typeof(CustomProxy));
            Mock <IClientPipeline> pipeline = new Mock <IClientPipeline>();

            IDummyInterface proxy = factory.CreateProxy <IDummyInterface>(pipeline.Object);

            Assert.Equal(10, proxy.Execute(false));
            Assert.True(((CustomProxy)proxy).Executed);
        }
示例#4
0
        public void ExecuteInterfaceMethod_Ok()
        {
            ProxyFactory           factory  = new ProxyFactory(typeof(CustomProxy));
            Mock <IClientPipeline> pipeline = new Mock <IClientPipeline>(MockBehavior.Strict);

            pipeline.Setup(p => p.Instance).Returns((ctxt) =>
            {
                ctxt.ActionResult = 5;
                return(Task.FromResult(true));
            });
            IDummyInterface proxy = factory.CreateProxy <IDummyInterface>(pipeline.Object);

            Assert.Equal(5, proxy.Execute2());
        }
示例#5
0
        public void ModifyReferenceAffectsOriginal_SystemObject([ValueSource(nameof(_systemObjects))] IDummyInterface dummy, [Random(1, int.MaxValue, 1)] int value)
        {
            Assert.That(_asset.InterfaceField.HasValue, Is.False);
            Assert.That(_asset.InterfaceField.IsSystemObject, Is.False);
            Assert.That(_asset.InterfaceField.IsUnityObject, Is.False);

            _asset.InterfaceField = new ManagedField <IDummyInterface>(dummy);
            Assert.That(_asset.InterfaceField.HasValue, Is.True);
            Assert.That(_asset.InterfaceField.IsSystemObject, Is.True);
            Assert.That(_asset.InterfaceField.IsUnityObject, Is.False);

            _asset.InterfaceField.Value.Integer = value;
            Assert.That(dummy.Integer, Is.EqualTo(value));
            Assert.That(dummy, Is.EqualTo(_asset.InterfaceField));
        }
 public ModelWithInterface(IDummyInterface dummyInterface)
 {
     _dummyInterface = dummyInterface;
 }