public void AcceptTest() { Keyboard keyboard = new Keyboard(); Mock <IComputerPartVisitor> mockComputerPartVisitor = new Mock <IComputerPartVisitor>(); keyboard.Accept(mockComputerPartVisitor.Object); mockComputerPartVisitor.Verify(visitor => visitor.Visit(keyboard), Times.Once()); }
private static void Visitor() { #region Visitor IComputerPart keyboard = new Keyboard(); keyboard.Accept(new ComputerPartDisplayVisitor()); // Computador encapsula todos os elementos. IComputerPart computer = new Computer(); computer.Accept(new ComputerPartDisplayVisitor()); #endregion Visitor }
/// <summary> /// called if the key is pressed /// executes the logical functionality depending on the keyType /// for LETTER: add the letter to the keyboard-text /// for BACK: remove the last char from the keyboard-text /// for ENTER: insert a new line if the maximum of lines is not exceeded /// for SHIFT: activate shift /// for CAPSLOCK: activate capslock /// for ACCEPT: tell the keyboard to finish the input /// for CANCEL: tell teh keyboard to cancle the input /// </summary> public void KeyPressed() { if (keyboard != null) { if (keyType == KeyType.LETTER) { // add the letter to the text keyboard.Text += letter; } else if (keyType == KeyType.BACK) { // remove the last letter from the text if (keyboard.Text.Length > 0) { keyboard.Text = keyboard.Text.Substring(0, keyboard.Text.Length - 1); } } else if (keyType == KeyType.ENTER) { keyboard.Text += Environment.NewLine; } else if (keyType == KeyType.SHIFT) { if (!keyboard.Capslock) { keyboard.Shift = !keyboard.Shift; } } else if (keyType == KeyType.CAPSLOCK) { keyboard.Capslock = !keyboard.Capslock; keyboard.Shift = keyboard.Capslock; capslockIndication.gameObject.SetActive(keyboard.Capslock); } else if (keyType == KeyType.ACCEPT) { keyboard.Accept(); } else { keyboard.Cancel(); } } }
void ReceiveMessage(NetworkMessage netMsg) { //Debug.Log(message); var m = netMsg.ReadMessage <MyMessage>(); string msg = m.msg; switch (m.tag) { case "Hide": connectWindow.SetActive(false); debugInfo.SetVisibility(false); break; case "TouchScreen Keyboard Width": if (msg == "+") { keyboard.ZoomIn(true); } else if (msg == "-") { keyboard.ZoomOut(true); } break; case "TouchScreen Keyboard Height": if (msg == "+") { keyboard.ZoomIn(false); } else if (msg == "-") { keyboard.ZoomOut(false); } break; case "TouchScreen Keyboard Size": if (msg == "+") { keyboard.ZoomIn(false, true); } else if (msg == "-") { keyboard.ZoomOut(false, true); } break; case "Get Keyboard Size": keyboard.SendSizeMsg(); break; case "Candidates": keyboard.SetCandidates(msg.Split(',')); break; case "Study1 New Phrase": keyboard.NewDataFile(msg, 1); break; case "Study2 New Phrase": keyboard.NewDataFile(msg, 2); break; case "Study1 End Phrase": case "Study2 End Phrase": keyboard.EndDataFile(msg); break; case "Accept": keyboard.Accept(msg); break; case "SingleKey": keyboard.SingleKey(msg); break; case "Cancel": keyboard.Cancel(); break; case "Delete": keyboard.Delete(msg); break; case "Expand": keyboard.Expand(); break; case "Backspace": keyboard.Backspace(); break; case "Change Ratio": keyboard.ChangeRatio(); break; case "NextCandidatePanel": keyboard.NextCandidatePanel(); break; default: Debug.Log("Unknown tag: " + tag); break; } }