public RegisterPageViewModel() { Login = new Command(async() => { if (await SQLiteDB.GetUserAsync(Usuario, Contraseña) is User) { await AlertAsync("Usuario no disponible", "El usuario que intenta registrar ya existe en la base de datos.", "Ok"); } else { if (Usuario.Length < 4 || Usuario.Length > 12) { await AlertAsync("Usuario inválido", "El usuario debe tener de 4 a 12 caracteres.", "Ok"); return; } if (Contraseña.Length < 4 || Contraseña.Length > 12) { await AlertAsync("Contraseña inválida", "La contraseña debe tener de 4 a 12 caracteres.", "Ok"); return; } SQLiteDB.Usuario = await SQLiteDB.RegisterAsync(Usuario, Contraseña); await AlertAsync("¡Registro exitoso!", "Su usuario ha sido registrado exitosamente.", "Ok"); Push.Execute(typeof(WelcomePage)); } }); }
public override IList <string> Execute(Stack stack) { var assemblyInstructions = new List <string>(); //Reset Function of context if (_context.FunctionNames.Count > 0) { _context.FunctionNames.Pop(); } //Set Function of context _context.FunctionNames.Push(_functionName); //Declare a Label Symbol for the function entry assemblyInstructions.Add($"({_functionName})"); //Allocate space on the stack for local variables, initialised to 0 var push = new Push(_context, "constant", "0"); var pushAssemblyInstructions = push.Execute(stack); for (int i = 0; i < _k_localVariables; i++) { assemblyInstructions.AddRange(pushAssemblyInstructions); } return(assemblyInstructions); }
public void Push_PushesValueOntoStack() { // Arrange var encoder = new Mock<IEncoder>(); var stack = new Mock<IStack>(); var context = new ExecutionContext { Encoder = encoder.Object, Stack = stack.Object }; var instruction = new Instruction { Operand = 12345 }; var pusher = new Push(); // Act pusher.Execute(context, instruction); // Assert stack.Verify(s => s.Push(It.IsAny<UInt64>()), Times.Once); }
public void Push_EncodesADataInstructionWithGivenOperand() { // Arrange var encoder = new Mock<IEncoder>(); var stack = new Mock<IStack>(); var context = new ExecutionContext { Encoder = encoder.Object, Stack = stack.Object }; var instruction = new Instruction { Operand = 12345 }; var pusher = new Push(); // Act pusher.Execute(context, instruction); // Assert encoder.Verify(e => e.Encode(It.Is<Instruction>(i => i.Operand == instruction.Operand && i.Type == InstructionType.Data))); }