예제 #1
0
        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>());
        }
예제 #2
0
        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);
        }
예제 #3
0
 private object ProxyFor(PropertyInfo property)
 {
     return(ProxyGenerator.Generate(property.PropertyType, _configuration));
 }
예제 #4
0
        public void Generate_GivenTypeAndDriver_InheritsFromPom()
        {
            var proxy = ProxyGenerator.Generate <PopgTestObject>(_fakeDriver);

            Assert.That(proxy.GetType().BaseType, Is.EqualTo(typeof(PopgTestObject)));
        }
예제 #5
0
        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')"));
        }
예제 #6
0
        public void Generate_GivenTypeAndDriver_GeneratesProxyThatPassesTypeCheck()
        {
            var proxy = ProxyGenerator.Generate <PopgTestObject>(_fakeDriver);

            Assert.That(proxy, Is.InstanceOf <PopgTestObject>());
        }