Skip to main content

Microsoft Silverlight

PasswordBoxAutomationPeer issue with IValueproviderRSS Feed

(0)

yuviusername
yuviuser...

Member

Member

4 points

6 Posts

PasswordBoxAutomationPeer issue with IValueprovider

Guys,

I am getting this error when I am trying to automate unit test for a simple Login page in a Silverlight application. Not sure whether this is a bug or not. Please clarify me what I need to do for running the test cases properly.

Error: Operation is not valid due to the current state of the object. 'passvalueProvider.Value' threw an exception of type 'System.InvalidOperationException'

 Error is happening at the line of "IValueProvider passvalueProvider = (IValueProvider)txtPassPeer;"

Code is here:

[TestMethod]

[Asynchronous]

public void TestAuthentication()

{

string exptUser = "Yuvaraj";

string exptPass = "Ilangovan";

TextBoxAutomationPeer txtUserPeer = new TextBoxAutomationPeer(_objLogin.txtUser);

IValueProvider uservalueProvider = (IValueProvider)txtUserPeer;

PasswordBoxAutomationPeer txtPassPeer = new PasswordBoxAutomationPeer(_objLogin.pwdPass);

//PasswordBox pBox = (PasswordBox)txtPassPeer.Owner;

IValueProvider passvalueProvider = (IValueProvider)txtPassPeer;

ButtonAutomationPeer buttonPeer = new ButtonAutomationPeer(_objLogin.btnSubmit);

IInvokeProvider buttonInvoker = (IInvokeProvider)buttonPeer;

uservalueProvider.SetValue("Yuvaraj");

passvalueProvider.SetValue("Ilangovan");

Assert.AreEqual(exptUser, uservalueProvider.Value);

Assert.AreEqual(exptPass, passvalueProvider.Value);

buttonInvoker.Invoke();

//EnqueueCallback(() => buttonInvoker.Invoke());

TestComplete();

//EnqueueTestComplete();

}

}

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities