private void PurchaseMethodBtn_Click(object sender, EventArgs e) { Notification status; Sms purchaseSms; string userPhoneNumber = this.userAccountTxtBox.Text; string userSms = this.smsTxtBox.Text; try { userPhoneNumber = systemParking.FormatPhoneNumber(userPhoneNumber); purchaseSms = systemParking.FormatSmsForPurchase(userSms); status = systemParking.ValidateSms(purchaseSms); status.AppendNotificationMessages(systemParking.ValidateExistingAccountForAccountTransaction(userPhoneNumber)); if (!status.HasErrors()) { Account purchaseAccount = systemParking.GetAccountByPhoneNumber(userPhoneNumber); status = systemParking.AddPurchase(new Purchase(purchaseSms, purchaseAccount)); } this.outputErrorLbl.Text = status.HasErrors()?$"Error: {status.Message()}":status.Message(); this.outputErrorLbl.ForeColor = status.HasErrors()? Color.Red:Color.Green; } catch (InvalidOperationException ex) { this.outputErrorLbl.Text = "Error: " + ex.Message; this.outputErrorLbl.ForeColor = Color.Red; } }
public void AddPurchaseTrueTest() { notification = system.AddPurchase(purchase); Assert.IsFalse(notification.HasErrors()); }