private IAttrDrivenTestPattern GetClientWrapper(AttributeDrivenPatternSchema schema, IUIAutomationPatternInstance patternInstance) { object wrapperObj; schema.Handler.CreateClientWrapper(patternInstance, out wrapperObj); return((IAttrDrivenTestPattern)wrapperObj); }
public void AttributeDrivenPatternSchema_AssertGuidsAreReflectedCorrectly() { var schema = new AttributeDrivenPatternSchema(typeof(IAttrDrivenTestProvider), typeof(IAttrDrivenTestPattern)); Assert.AreEqual(new Guid(TestPatternProviderComGuid), schema.PatternProviderGuid); Assert.AreEqual(new Guid(TestPatternClientComGuid), schema.PatternClientGuid); Assert.AreEqual(new Guid(TestPatternGuid), schema.PatternGuid); }
public void PatternHandler_VoidParameterlessMethodCalled_DispatchedCorrectly() { var schema = new AttributeDrivenPatternSchema(typeof(IAttrDrivenTestProvider), typeof(IAttrDrivenTestPattern)); schema.Register(); var pParams = new UIAutomationParameter[0]; var p = Substitute.For <IAttrDrivenTestProvider>(); schema.Handler.Dispatch(p, schema.Methods[0].Index, pParams, 0); p.Received().VoidParameterlessMethod(); }
public void ClientWrapper_CachedPropertyCalled_MakesCorrectRequestToPatternInstance() { var schema = new AttributeDrivenPatternSchema(typeof(IAttrDrivenTestProvider), typeof(IAttrDrivenTestPattern)); schema.Register(); var patternInstance = Substitute.For <IUIAutomationPatternInstance>(); var wrapper = GetClientWrapper(schema, patternInstance); var propHelper = schema.Properties.First(p => p.Data.pProgrammaticName == Provider.IntPropertyProperty.Name); var verifier = ExpectCachedPropertyCall(patternInstance, propHelper, returnValue: 42); var val = wrapper.CachedIntProperty; verifier(); Assert.AreEqual(42, val); }
public void PatternHandler_DispatchesPropertiesCorrectly() { var schema = new AttributeDrivenPatternSchema(typeof(IAttrDrivenTestProvider), typeof(IAttrDrivenTestPattern)); schema.Register(); var paramHelper = new UiaParameterHelper(UIAutomationType.UIAutomationType_OutBool); var pParams = new[] { paramHelper.ToUiaParam() }; var p = Substitute.For <IAttrDrivenTestProvider>(); p.BoolProperty.Returns(true); schema.Handler.Dispatch(p, schema.Properties[0].Index, pParams, 1); Assert.AreEqual(true, paramHelper.Value); p.BoolProperty.Returns(false); schema.Handler.Dispatch(p, schema.Properties[0].Index, pParams, 1); Assert.AreEqual(false, paramHelper.Value); }
public void ClientWrapper_BoolMethodWithIntAndOutStringParamsCalled_MakesCorrectRequestToPatternInstance() { var schema = new AttributeDrivenPatternSchema(typeof(IAttrDrivenTestProvider), typeof(IAttrDrivenTestPattern)); schema.Register(); var patternInstance = Substitute.For <IUIAutomationPatternInstance>(); var wrapper = GetClientWrapper(schema, patternInstance); var methodHelper = schema.Methods.First(m => m.Data.pProgrammaticName == Provider.BoolMethodWithInAndOutParams.Name); var inArgs = new object[] { 42, null, null }; var outArgs = new object[] { null, "abc", true }; var verifier = ExpectMethodCall(patternInstance, methodHelper, inArgs, outArgs); string strResult; var boolResult = wrapper.BoolMethodWithInAndOutParams(42, out strResult); verifier(); Assert.AreEqual("abc", strResult); Assert.AreEqual(true, boolResult); }
public void AttributeDrivenPatternSchema_PropertiesAndMethodsAreMappedCorrectly() { var schema = new AttributeDrivenPatternSchema(typeof(IAttrDrivenTestProvider), typeof(IAttrDrivenTestPattern)); var props = schema.Properties; Assert.AreEqual(2, props.Length); AssertPropertyInfo("BoolProperty", UIAutomationType.UIAutomationType_Bool, TestPatternBoolPropertyGuid, props[0]); AssertPropertyInfo("IntProperty", UIAutomationType.UIAutomationType_Int, TestPatternIntPropertyGuid, props[1]); Assert.AreEqual(4, schema.Methods.Length); var voidParamlessMethod = schema.Methods.Single(m => m.Data.pProgrammaticName == Provider.VoidParameterlessMethod.Name); Assert.AreEqual(0, voidParamlessMethod.Data.cInParameters); Assert.AreEqual(0, voidParamlessMethod.Data.cOutParameters); var boolParamlessMethodWithSetFocus = schema.Methods.Single(m => m.Data.pProgrammaticName == Provider.BoolParameterlessMethodWithDoSetFocus.Name); Assert.AreEqual(1, boolParamlessMethodWithSetFocus.Data.doSetFocus); Assert.AreEqual(0, boolParamlessMethodWithSetFocus.Data.cInParameters); Assert.AreEqual(1, boolParamlessMethodWithSetFocus.Data.cOutParameters); Assert.AreEqual(UIAutomationType.UIAutomationType_OutBool, boolParamlessMethodWithSetFocus.OutParamTypes[0]); var boolMethodWithInOutParams = schema.Methods.Single(m => m.Data.pProgrammaticName == Provider.BoolMethodWithInAndOutParams.Name); Assert.AreEqual(1, boolMethodWithInOutParams.Data.cInParameters); Assert.AreEqual(2, boolMethodWithInOutParams.Data.cOutParameters); Assert.AreEqual(UIAutomationType.UIAutomationType_Int, boolMethodWithInOutParams.InParamTypes[0]); Assert.AreEqual(UIAutomationType.UIAutomationType_OutString, boolMethodWithInOutParams.OutParamTypes[0]); Assert.AreEqual(UIAutomationType.UIAutomationType_OutBool, boolMethodWithInOutParams.OutParamTypes[1]); var intMethodWithDoubleParam = schema.Methods.Single(m => m.Data.pProgrammaticName == Provider.IntMethodWithDoubleParam.Name); Assert.AreEqual(1, intMethodWithDoubleParam.Data.cInParameters); Assert.AreEqual(1, intMethodWithDoubleParam.Data.cOutParameters); Assert.AreEqual(UIAutomationType.UIAutomationType_Double, intMethodWithDoubleParam.InParamTypes[0]); Assert.AreEqual(UIAutomationType.UIAutomationType_OutInt, intMethodWithDoubleParam.OutParamTypes[0]); }
public void AttributeDrivenPatternSchema_AssertRegistrationGoesSmoothly() { var schema = new AttributeDrivenPatternSchema(typeof(IAttrDrivenTestProvider), typeof(IAttrDrivenTestPattern)); schema.Register(); }