public void Generate_GivenTypeAndDriver_ReturnsInterceptedType() { var proxy = ProxyGenerator.Generate <PopgTestObject>(_fakeDriver); var interceptor = ((IInterceptor[])proxy.GetType() .GetFields(BindingFlags.Instance | BindingFlags.NonPublic) .Single(x => x.Name == "__interceptors") .GetValue(proxy)).Single(); Assert.That(interceptor, Is.TypeOf <PageObjectProxy>()); }
public void PostProcessReturnValue(IInvocation invocation) { if (invocation.ReturnValue == null || !invocation.ReturnValue.IsAProxy()) { return; } if (invocation.ReturnValue.GetType().IsAPageTransitionObject()) { var rebaseUri = invocation.ReturnValue.GetRebaseOn(); if (!string.IsNullOrWhiteSpace(rebaseUri)) { _configuration.WebRoot = rebaseUri; } invocation.ReturnValue = ProxyGenerator.GenerateWrappedPageObject(invocation.Method.ReturnType.GetGenericParam(), _configuration); return; } invocation.ReturnValue = invocation.Method.ReturnType.IsAPageObject() ? ProxyGenerator.GenerateWrappedPageObject(invocation.Method.ReturnType.GetGenericParam(), _configuration) : ProxyGenerator.Generate(invocation.Method.ReturnType, _configuration); }
private object ProxyFor(PropertyInfo property) { return(ProxyGenerator.Generate(property.PropertyType, _configuration)); }
public void Generate_GivenTypeAndDriver_InheritsFromPom() { var proxy = ProxyGenerator.Generate <PopgTestObject>(_fakeDriver); Assert.That(proxy.GetType().BaseType, Is.EqualTo(typeof(PopgTestObject))); }
public void Generate_PassedNullDriverBindings_Throws() { var ex = Assert.Throws <ArgumentNullException>(() => ProxyGenerator.Generate <PopgTestObject>(null)); Assert.That(ex.Message, Is.EqualTo("Value cannot be null. (Parameter 'configuration')")); }
public void Generate_GivenTypeAndDriver_GeneratesProxyThatPassesTypeCheck() { var proxy = ProxyGenerator.Generate <PopgTestObject>(_fakeDriver); Assert.That(proxy, Is.InstanceOf <PopgTestObject>()); }