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)); }
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); }
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); }
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()); }
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; }