public static void addAndRemoveCreditCard() { ClubMember buyer = new ClubMember("9999", "Tal", "Mosseri", "Male", "10/08/1175"); string creditNumber = "1234567890654321"; string cvv = "356"; string monthExp = "07"; string yearExp = "2000"; buyer.addCreditCard(creditNumber, monthExp, yearExp, cvv); Assert.IsTrue(hasCradit(buyer)); buyer.removeCreditCard(); Assert.IsFalse(hasCradit(buyer)); }
private void save2_Click(object sender, RoutedEventArgs e) { string number = creditNumber.Text; string cvvNum = cvv.Text; DateTime date = (DateTime)calander.SelectedDate; try { if (date == null) { throw new Exception("you have to choose expiery date"); } //string[] dataArr = date.Split('/', ' '); //string month = dataArr[1]; //string year = dataArr[2]; //char[] chYear = year.ToCharArray(); //string exYear = Convert.ToString(chYear[2]) + Convert.ToString(chYear[3]); if (number.Length != 16) { throw new Exception("the credit number must contain 16 numbers"); } if (cvvNum.Length != 3) { throw new Exception("the CVV number must be 3-digit code"); } isClub.addCreditCard(number, date.Month.ToString(), date.Year.ToString(), cvvNum); MessageBox.Show("Successfully saved"); rightSplite2.Visibility = Visibility.Collapsed; } catch (Exception ex) { MessageBox.Show(ex.Message); } }