示例#1
0
        internal virtual CustomCommandResponse Do(string assemblyFile, string typeName, MethodInfo method,
                                                  object[] arguments)
        {
            var valuePattern = Pattern(ValuePattern.Pattern) as ValuePattern;

            if (valuePattern == null)
            {
                throw new CustomCommandException(string.Format("{0} does not implement ValuePattern",
                                                               automationElement.Display()));
            }
            CustomCommandResponse response = Execute(valuePattern, assemblyFile, typeName, method, arguments);

            if (response.IsValidResponse)
            {
                return(response);
            }

            var    commandSerializer         = new CustomCommandSerializer();
            string serializedAssemblyRequest = commandSerializer.SerializeAssembly(assemblyFile);

            valuePattern.SetValue(serializedAssemblyRequest);

            response = Execute(valuePattern, assemblyFile, typeName, method, arguments);
            valuePattern.SetValue(commandSerializer.SerializeEndSession());
            return(response);
        }
        public void IsValidResponse()
        {
            var response = new CustomCommandResponse(new object[1] {
                null
            });

            Assert.AreEqual(true, response.IsValidResponse);
        }
示例#3
0
        public void ExceptionThrownInSetValueIsReturnedWhenGetValueIsCalled()
        {
            WhitePeer whitePeer = WhitePeer.Create(new TestAutomationPeer(), new TestControl());

            whitePeer.SetValue(commandSerializer.SerializeAssembly(typeof(IExceptionCommand).Assembly.Location));

            string serializedCommand = commandSerializer.Serialize(new FileInfo(typeof(IExceptionCommand).Assembly.Location).Name, typeof(IExceptionCommand).FullName, "ThrowException", new object[0]);

            whitePeer.SetValue(serializedCommand);
            var response        = commandSerializer.ToObject(whitePeer.Value);
            var commandResponse = new CustomCommandResponse(response);

            Assert.AreEqual(true, commandResponse.IsException);
            response        = commandSerializer.ToObject(whitePeer.Value);
            commandResponse = new CustomCommandResponse(response);
            Assert.AreEqual(true, commandResponse.IsException);
        }