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); }
public virtual void Intercept(IInvocation invocation) { if (uiItem.AutomationElement == null) { throw new NullReferenceException("AutomationElement in this UIItem is null"); } Type type = invocation.Method.DeclaringType; string assemblyFileName = new FileInfo(type.Assembly.Location).FullName; CustomCommandResponse response = uiItem.Do(assemblyFileName, type.FullName, invocation.Method, invocation.Arguments); if (response.IsException) { throw new WhiteException(string.Format("Exception when executing command. Exception Details: {0}", response.Exception)); } invocation.ReturnValue = response.ReturnValue; }
public void IsValidResponse() { var response = new CustomCommandResponse(new object[1] {null}); Assert.AreEqual(true, response.IsValidResponse); }