private async void ShowPasswordForm(int tryCount, int maxCount) { var dialog1 = new PasswordInputDialog(); dialog1.Title = "Input your password (" + tryCount + "/" + maxCount + ")"; await dialog1.ShowAsync(); _controller?.InputPassword(dialog1.Text); }
public async Task SetUp() { FinalizeClient(); await Task.Delay(1000); _controller = new PenController(); _client = new BluetoothPenClient(_controller); TypedEventHandler <IPenClient, object> authenticated = new TypedEventHandler <IPenClient, object>((IPenClient sender, object obj) => { _autoResetEvent.Set(); }); _controller.Authenticated += authenticated; TypedEventHandler <IPenClient, PasswordRequestedEventArgs> passwordRequested = new TypedEventHandler <IPenClient, PasswordRequestedEventArgs>((IPenClient sender, PasswordRequestedEventArgs args) => { _controller.InputPassword(PASSWORD); }); _controller.PasswordRequested += passwordRequested; _client.Connect(MAC).Wait(); if (!_client.Alive) { Assert.Fail("connection failed"); return; } _autoResetEvent.WaitOne(); _controller.Authenticated -= authenticated; _controller.PasswordRequested -= passwordRequested; }
public void TestInputPassword() { bool result = false; _controller.PasswordChanged += (IPenClient sender, SimpleResultEventArgs args) => { _client.Disconnect(); _autoResetEvent.Set(); }; _controller.Authenticated += (IPenClient sender, object args) => { result = true; _autoResetEvent.Set(); }; _controller.PasswordRequested += (IPenClient sender, PasswordRequestedEventArgs args) => { _controller.InputPassword(PASSWORD); }; Task.Factory.StartNew(() => { //1234로 비밀번호 변경 _controller.SetPassword("", PASSWORD); }); _autoResetEvent.WaitOne(); _client.Connect(MAC).Wait(); bool connResult = _client.Alive; _autoResetEvent.WaitOne(); Assert.IsTrue(result && connResult); }