private void AcceptRemoveBasicUserButton_Click(object sender, EventArgs e) { // Remove respectively basic user from database try { // Connect with database MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository( platformType: SystemSettings._PlatformType); mockBasicUsersRepository.Remove(basicUserId: this.basicUserToRemove._Id); } catch (MockBasicUsersRepository_Exception mbur_e) { } // Redirect to administrator remove basic user result panel AdministratorRemoveBasicUserResultPanel administratorRemoveBasicUserResultPanel = new AdministratorRemoveBasicUserResultPanel(); administratorRemoveBasicUserResultPanel.ShowDialog(); this.Close(); }
public LoginPanel() { InitializeComponent(); // Set System Settings SystemSettings._PlatformType = PlatformType.Windows; // Set autoincrement value try { MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository(SystemSettings._PlatformType); User._Id_counter = (mockBasicUsersRepository.GetAll().Last()._Id + 1); } catch (MockBasicUsersRepository_Exception mbur_e) { } // Set Pin Code TextBox this.PinCodeTextBox.PasswordChar = '*'; // Set Error Label this.ErrorLabel.Hide(); }
private void AddBasicUserButton_Click(object sender, System.EventArgs e) { // Redirect to add basic user panel AdministratorAddBasicUserPanel administratorAddBasicUserPanel = new AdministratorAddBasicUserPanel(); administratorAddBasicUserPanel.ShowDialog(); // Update grid view information try { // Connect with database MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository(SystemSettings._PlatformType); // Get basic users var basicUsersDataGridViewModels = mockBasicUsersRepository.GetAll().Select((singleBasicUser) => { return(new BasicUsersDataGridViewModel { BasicUserId = singleBasicUser._Id, accountState = singleBasicUser._BankAccount.state._Value, pin = singleBasicUser._Pin._Value, name = singleBasicUser._Name._Value, surname = singleBasicUser._Surname._Value }); }).ToList(); this.BasicUsersDataGridView.DataSource = basicUsersDataGridViewModels; } catch (MockBasicUsersRepository_Exception mbur_e) { } }
public void MockBasicUsersRepository_When_Get( string[] basicUsersData, int basicUserId, string basicUserPin, string basicUserName, string basicUserSurname, decimal basicUserBankAccountValue, Currency basicUserBankAccountCurrency, string expected) { string result = "OK"; //arrange using (StreamWriter sw = new StreamWriter( (cashDispenserLibraryTestSettings._SystemSettings == PlatformType.Windows) ? "cashDispenserDatabase\\BasicUsers.txt" : "cashDispenserDatabase/BasicUsers.txt", false)) { foreach (var basicUserData in basicUsersData) { sw.WriteLine(basicUserData); } } //act //Connect with database MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository( cashDispenserLibraryTestSettings._SystemSettings); //Get information about respectively basic user BasicUser gotBasicUser = null; try { gotBasicUser = mockBasicUsersRepository.Get(basicUserId: basicUserId); } catch (MockBasicUsersRepository_Exception mbur_e) { result = mbur_e.What(); } //Check got basic user if (result.Equals("OK")) { if ((gotBasicUser._Id != basicUserId) || (!(gotBasicUser._Pin._Value.Equals(basicUserPin))) || (!(gotBasicUser._Name._Value.Equals(basicUserName))) || (!(gotBasicUser._Surname._Value.Equals(basicUserSurname))) || (gotBasicUser._BankAccount.state._Value != basicUserBankAccountValue) || (gotBasicUser._BankAccount.state._Currency != basicUserBankAccountCurrency)) { result = "!!! Issue with get basic user !!!"; } } //assert Assert.AreEqual(expected: expected, actual: result); }
public void MockBasicUsersRepository_When_Remove( string[] basicUsersData, int basicUserId, string expected) { string result = "OK"; //arrange using (StreamWriter sw = new StreamWriter( (cashDispenserLibraryTestSettings._SystemSettings == PlatformType.Windows) ? "cashDispenserDatabase\\BasicUsers.txt" : "cashDispenserDatabase/BasicUsers.txt", false)) { foreach (var basicUserData in basicUsersData) { sw.WriteLine(basicUserData); } } //act //Connect with database MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository( cashDispenserLibraryTestSettings._SystemSettings); //Remove basic user try { mockBasicUsersRepository.Remove(basicUserId: basicUserId); } catch (MockBasicUsersRepository_Exception mbur_e) { result = mbur_e.What(); } //Check remove's result if (result.Equals("OK")) { try { mockBasicUsersRepository.Get(basicUserId: basicUserId); } catch (MockBasicUsersRepository_Exception mbur_e) { result = mbur_e.What(); } } //assert Assert.AreEqual(expected: expected, actual: result); }
public void BasicUser_When_Add_Money( decimal addCurrencyRate, decimal addValue, Currency addCurrency, string expected) { string result = "OK"; //arrange BasicUser basicUser = null; //Init database initData(); //Init basic users database using (StreamWriter sw = new StreamWriter( "cashDispenserDatabase/BasicUsers.txt", false)) { basicUser = new BasicUser( id: 0, pin: new PinVAL(value: "1111"), name: new NameVAL(value: "Imię"), surname: new SurnameVAL(value: "Nazwisko"), bankAccount: new BankAccount( state: new MoneyVAL( value: PhysicalMoney_txt, currency: Currency.PLN))); sw.WriteLine($"0;1111;Imię;Nazwisko;{PhysicalMoney_txt.ToString(new CultureInfo("en-US"))};0"); } //Get respectively basic user's from database try { MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository( cashDispenserLibraryTestSettings._SystemSettings); basicUser = mockBasicUsersRepository.Get( basicUserId: 0); } catch (MockBasicUsersRepository_Exception mbur_e) { result = mbur_e.What(); } //act if (result.Equals("OK")) { //Add money try { basicUser._BankAccount.AddMoney(currencyRate: addCurrencyRate, money: new MoneyVAL(value: addValue, currency: addCurrency), basicUser); } catch (MoneyVAL_Exception m_e) { result = m_e.What(); } catch (BankAccount_Exception ba_e) { result = ba_e.What(); } catch (Exception ex) { result = "!!! Issue with open file !!!"; } if (result.Equals("OK")) { //---Check physical money repository state--- //Connect with database MockPhysicalMoneyRepository mockPhysicalMoneyRepository = new MockPhysicalMoneyRepository( cashDispenserLibraryTestSettings._SystemSettings); //Get physical money state PhysicalMoneyVAL physicalMoneyState = null; try { physicalMoneyState = mockPhysicalMoneyRepository.GetInCurrency( currencyRate: 1.0M, currency: Currency.PLN); } catch (MockPhysicalMoneyRepository_Exception mpmr_e) { result = mpmr_e.What(); } catch (Exception ex) { result = "!!! Issue with open file !!!"; } if (result.Equals("OK")) { //Check database value if ((physicalMoneyState._Value - (addValue * addCurrencyRate)) != PhysicalMoney_txt) { result = "Bad database value"; } if (physicalMoneyState._Currency != Currency.PLN) { result = "Bad database currency"; } } } } //assert Assert.AreEqual(expected: expected, actual: result); }
public void BankAccount_When_Add_Money( string[] basicUsersData, decimal addCurrencyRate, decimal addValue, Currency addCurrency, int basicUserId, string expected) { string result = "OK"; //arrange BankAccount bankAccount = null; BasicUser basicUser = null; decimal beginBasicUserBankAccountState = -1; //Init database initData(); //Init basic users database using (StreamWriter sw = new StreamWriter( "cashDispenserDatabase/BasicUsers.txt", false)) { foreach (var basicUserData in basicUsersData) { sw.WriteLine(basicUserData); } } //Get respectively basic user's from database try { MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository( cashDispenserLibraryTestSettings._SystemSettings); basicUser = mockBasicUsersRepository.Get( basicUserId: basicUserId); } catch (MockBasicUsersRepository_Exception mbur_e) { result = mbur_e.What(); } //Get basic user's begin account state if (result.Equals("OK")) { beginBasicUserBankAccountState = basicUser._BankAccount.state._Value; } if (result.Equals("OK")) { //Create bank account base on respectively basic user try { bankAccount = new BankAccount(state: new MoneyVAL( value: basicUser._BankAccount.state._Value, currency: Currency.PLN)); } catch (MoneyVAL_Exception mv_e) { result = mv_e.What(); } catch (BankAccount_Exception ba_e) { ba_e.What(); } //act if (result.Equals("OK")) { //Add money try { bankAccount.AddMoney(currencyRate: addCurrencyRate, money: new MoneyVAL(value: addValue, currency: addCurrency), basicUser); } catch (MoneyVAL_Exception m_e) { result = m_e.What(); } catch (BankAccount_Exception ba_e) { result = ba_e.What(); } catch (Exception ex) { result = "!!! Issue with open file !!!"; } if (result.Equals("OK")) { //---Check physical money repository state--- //Connect with database MockPhysicalMoneyRepository mockPhysicalMoneyRepository = new MockPhysicalMoneyRepository( cashDispenserLibraryTestSettings._SystemSettings); //Get physical money state PhysicalMoneyVAL physicalMoneyState = null; try { physicalMoneyState = mockPhysicalMoneyRepository.GetInCurrency( currencyRate: 1.0M, currency: Currency.PLN); } catch (MockPhysicalMoneyRepository_Exception mpmr_e) { result = mpmr_e.What(); } catch (Exception ex) { result = "!!! Issue with open file !!!"; } if (result.Equals("OK")) { //Check database value if ((physicalMoneyState._Value - (addValue * addCurrencyRate)) != PhysicalMoney_txt) { result = "Bad database value"; } //Check database currency if (physicalMoneyState._Currency != Currency.PLN) { result = "Bad database currency"; } //--- Check basic user's bank account state in //repository state --- //Connect with database try { MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository( cashDispenserLibraryTestSettings._SystemSettings); basicUser = mockBasicUsersRepository.Get( basicUserId: basicUserId); } catch (MockBasicUsersRepository_Exception mbur_e) { result = mbur_e.What(); } //Check basic user money's state if (result.Equals("OK")) { if (Math.Abs((basicUser._BankAccount.state._Value - addValue * addCurrencyRate) - beginBasicUserBankAccountState) > 0.002M) { result = "Bad basic user money database result value"; } if (basicUser._BankAccount.state._Currency != Currency.PLN) { result = "Bad basic user money database result currency"; } } } } } //assert Assert.AreEqual(expected: expected, actual: result); } }
private void AcceptButton_Click(object sender, EventArgs e) { // Pin Code PinVAL pinCode = null; // Validate Pin Code try { pinCode = new PinVAL(PinCodeTextBox.Text); } catch (PinVAL_Exception p_e) { ErrorLabel.Text = p_e.What(); ErrorLabel.Show(); } if (pinCode != null) { // Login basic user if (pinCode._Value.Length == 4) { try { // Connect with basic users database MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository(SystemSettings._PlatformType); // Get information about basic user with respectively pin code // from database BasicUserPanelVM basicUserPanelVM = new BasicUserPanelVM { basicUser = mockBasicUsersRepository.GetAll().FirstOrDefault( (singleBasicUser) => singleBasicUser._Pin._Value == pinCode._Value) }; // Check basic user's find result if (basicUserPanelVM.basicUser != null) { // Redirect to Basic User Panel basicUserPanelVM.loginPanel = this; BasicUserPanel basicUserPanel = new BasicUserPanel(basicUserPanelVM); this.PinCodeTextBox.Clear(); this.ErrorLabel.Hide(); basicUserPanel.Show(); this.Hide(); } else { ErrorLabel.Text = "!!! Użytkownik O Podanym Pinie Nie Istnieje !!!"; ErrorLabel.Show(); } } catch (MockBasicUsersRepository_Exception mbur_e) { ErrorLabel.Text = mbur_e.What(); ErrorLabel.Show(); } } // Login administrator else if (pinCode._Value.Length == 6) { try { // Connect with administrators database MockAdministratorsRepository mockAdministratorsRepository = new MockAdministratorsRepository(SystemSettings._PlatformType); // Get information about administrator with respectively pin code // from database AdministratorPanelVM administratorPanelVM = new AdministratorPanelVM { administrator = mockAdministratorsRepository.GetAll(). FirstOrDefault((singleAdministrator) => singleAdministrator._Pin._Value == pinCode._Value) }; // Check administrator's find result if (administratorPanelVM.administrator != null) { // Redirect to administrator panel administratorPanelVM.loginPanel = this; AdministratorPanel administratorPanel = new AdministratorPanel(administratorPanelVM); this.PinCodeTextBox.Clear(); this.ErrorLabel.Hide(); administratorPanel.Show(); this.Hide(); } else { ErrorLabel.Text = "!!! Użytkownik O Podanym Pinie Nie Istnieje !!!"; ErrorLabel.Show(); } } catch (MockAdministratorsRepository_Exception mar_e) { ErrorLabel.Text = mar_e.What(); ErrorLabel.Show(); } } } }
private void UpdateBasicUserButton_Click(object sender, EventArgs e) { // Get basic user's informations to update string basicUserName = this.NameValueTextBox.Text; string basicUserSurname = this.SurnameValueTextBox.Text; string basicUserPin = this.PinValueTextBox.Text; decimal basicUserAccountState = ((this.AccountStateValueTextBox.Text.Length > 0) ? decimal.Parse( this.AccountStateValueTextBox.Text.Replace(',', '.'), CultureInfo.InvariantCulture) : 0.0M); // Update basic user try { // Connect with database MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository(SystemSettings._PlatformType); // Fill basic user's object new informations this.basicUser.ChangeName(name: new NameVAL( value: this.NameValueTextBox.Text)); this.basicUser.ChangeSurname(surname: new SurnameVAL( value: this.SurnameValueTextBox.Text)); this.basicUser.ChangePin(pin: new PinVAL( value: this.PinValueTextBox.Text)); this.basicUser._BankAccount.state.ChangeMoney( moneyVAL: new MoneyVAL(value: decimal.Parse( this.AccountStateValueTextBox.Text, CultureInfo.InvariantCulture), currency: Currency.PLN)); // Update new basic user's record mockBasicUsersRepository.Update(basicUser: this.basicUser); // Show update new basic user result AdministratorUpdateBasicUserResultPanel administratorUpdateBasicUserResultPanel = new AdministratorUpdateBasicUserResultPanel(); administratorUpdateBasicUserResultPanel.ShowDialog(); this.Dispose(); } catch (NameVAL_Exception n_e) { this.ErrorLabel.Text = n_e.What(); this.ErrorLabel.Show(); } catch (SurnameVAL_Exception s_e) { this.ErrorLabel.Text = s_e.What(); this.ErrorLabel.Show(); } catch (PinVAL_Exception p_e) { this.ErrorLabel.Text = p_e.What(); this.ErrorLabel.Show(); } catch (BankAccount_Exception b_e) { this.ErrorLabel.Text = b_e.What(); this.ErrorLabel.Show(); } catch (MoneyVAL_Exception m_e) { this.ErrorLabel.Text = m_e.What(); this.ErrorLabel.Show(); } }
public MoneyVAL TakeOutMoney( decimal currencyRate, MoneyVAL money, BasicUser user) { //Validate currency rate if (currencyRate <= 0.0M) { throw new BankAccount_Exception( BankAccount_ExceptionType.BadCurrencyRate); } //Core currency case if (money._Currency == Currency.PLN) { //Take out money from account if (money._Value <= state._Value) { //Arrange bank account database connection MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository( platformType: SystemSettings._PlatformType); //Update Basic user account state var basicUser = mockBasicUsersRepository.Get( basicUserId: user._Id); basicUser._BankAccount.state.ChangeMoney( moneyVAL: new MoneyVAL( value: (basicUser._BankAccount.state._Value - money._Value), currency: Currency.PLN)); //Save changes mockBasicUsersRepository.Update(basicUser); //Arrange physical money database connection MockPhysicalMoneyRepository mockPhysicalMoneyRepository = new MockPhysicalMoneyRepository( SystemSettings._PlatformType); //Update bank account state state.ChangeMoney(new MoneyVAL( value: (state._Value - money._Value), currency: Currency.PLN)); //Update physical money state PhysicalMoneyVAL mockPhysicalMoney = mockPhysicalMoneyRepository.GetInCurrency( currencyRate: currencyRate, currency: Currency.PLN); mockPhysicalMoneyRepository.UpdateInCurrency( currencyRate: currencyRate, new PhysicalMoneyVAL( value: (mockPhysicalMoney._Value - money._Value), currency: Currency.PLN)); //Take out money return(money); } //To little money to take out money case else { throw new BankAccount_Exception( BankAccount_ExceptionType.TooLittleMoney); } } //Others currency case else { //Take out money from account if (money._Value <= (state._Value / currencyRate)) { //Arrange bank account database connection MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository( platformType: SystemSettings._PlatformType); //Update Basic user account state var basicUser = mockBasicUsersRepository.Get( basicUserId: user._Id); basicUser._BankAccount.state.ChangeMoney( moneyVAL: new MoneyVAL( value: (basicUser._BankAccount.state._Value - (money._Value * currencyRate)), currency: Currency.PLN)); //Save changes mockBasicUsersRepository.Update(basicUser); //Arrange physical money database connection MockPhysicalMoneyRepository mockPhysicalMoneyRepository = new MockPhysicalMoneyRepository(SystemSettings._PlatformType); //Update bank account state state.ChangeMoney(new MoneyVAL( value: (state._Value - (money._Value * currencyRate)), currency: Currency.PLN)); //Update physical money state PhysicalMoneyVAL mockPhysicalMoney = mockPhysicalMoneyRepository.GetInCurrency( currencyRate: currencyRate, currency: money._Currency); mockPhysicalMoneyRepository.UpdateInCurrency( currencyRate: currencyRate, new PhysicalMoneyVAL( value: (mockPhysicalMoney._Value - money._Value), currency: money._Currency)); //Take out money return(money); } //To little money to take out money case else { throw new BankAccount_Exception( BankAccount_ExceptionType.TooLittleMoney); } } }
public AdministratorManageBasicUsersPanel( AdministratorManageBasicUsersPanelVM administratorManageBasicUsersPanelVM) { InitializeComponent(); // Set login panel information this.loginPanel = administratorManageBasicUsersPanelVM.loginPanel; // Set administrator panel information this.administratorPanel = administratorManageBasicUsersPanelVM.administratorPanel; // Set administrator information this.administrator = administratorManageBasicUsersPanelVM.administrator; // Set selected basic users data grid view row try { MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository(SystemSettings._PlatformType); this.selectedBasicUsersDataGridViewRow = mockBasicUsersRepository.GetAll().First(); } catch (MockBasicUsersRepository_Exception mbur_e) { } // Set grid view information try { // Connect with database MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository(SystemSettings._PlatformType); // Get basic users var basicUsersDataGridViewModels = mockBasicUsersRepository.GetAll().Select((singleBasicUser) => { return(new BasicUsersDataGridViewModel { BasicUserId = singleBasicUser._Id, pin = singleBasicUser._Pin._Value, name = singleBasicUser._Name._Value, surname = singleBasicUser._Surname._Value, accountState = singleBasicUser._BankAccount.state._Value }); }).ToList(); this.BasicUsersDataGridView.DataSource = basicUsersDataGridViewModels; } catch (MockBasicUsersRepository_Exception mbur_e) { } // Set column headers names this.BasicUsersDataGridView.Columns[0].HeaderText = "Id"; this.BasicUsersDataGridView.Columns[0].Visible = false; this.BasicUsersDataGridView.Columns[1].HeaderText = "Pin"; this.BasicUsersDataGridView.Columns[2].HeaderText = "Imię"; this.BasicUsersDataGridView.Columns[3].HeaderText = "Nazwisko"; this.BasicUsersDataGridView.Columns[4].HeaderText = "Stan Konta"; // Show administration information this.AdministratorInformationLabel.Text = ("Zalogowano Jako :" + $"{this.administrator._Name._Value} {this.administrator._Surname._Value}"); // Center basic user data grid view columns headers foreach (DataGridViewColumn basicUsersDataGridViewColumn in this.BasicUsersDataGridView.Columns) { basicUsersDataGridViewColumn.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; } }
public void MockBasicUsersRepository_When_Get_All( string[] basicUsersData, string expected) { string result = "OK"; //arrange var mockBasicUsers = new List <BasicUser>(); var insertBasicUsers = new List <string[]>(); //Convert basic users data foreach (var basicUserData in basicUsersData) { insertBasicUsers.Add(basicUserData.Split(';')); } //Save basic users data using (StreamWriter sw = new StreamWriter( (cashDispenserLibraryTestSettings._SystemSettings == PlatformType.Windows) ? "cashDispenserDatabase\\BasicUsers.txt" : "cashDispenserDatabase/BasicUsers.txt", false)) { foreach (var basicUserData in basicUsersData) { sw.WriteLine(basicUserData); } } //act //Connect with database MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository( cashDispenserLibraryTestSettings._SystemSettings); //Get all basic users try { mockBasicUsers = mockBasicUsersRepository.GetAll().ToList(); } catch (MockBasicUsersRepository_Exception mbur_e) { result = mbur_e.What(); } if (result.Equals("OK")) { //Check got basic users for (int i = 0; i < insertBasicUsers.Count; ++i) { if ((!(mockBasicUsers[i]._Id.ToString().Equals(insertBasicUsers[i][0]))) || (!(mockBasicUsers[i]._Pin._Value.Equals(insertBasicUsers[i][1]))) || (!(mockBasicUsers[i]._Name._Value.Equals(insertBasicUsers[i][2]))) || (!(mockBasicUsers[i]._Surname._Value.Equals(insertBasicUsers[i][3]))) || (!(mockBasicUsers[i]._BankAccount.state._Value.ToString( new CultureInfo("en-US")).Equals(insertBasicUsers[i][4]))) || (mockBasicUsers[i]._BankAccount.state._Currency != Currency.PLN)) { result = "!!! Issue with get basic user !!!"; } } } //assert Assert.AreEqual(expected: expected, actual: result); }
public void MockBasicUsersRepository_When_Add( string[] basicUsersData, int basicUserId, string basicUserPin, string basicUserName, string basicUserSurname, decimal basicUserBankAccountValue, Currency basicUserBankAccountCurrency, string expected) { string result = "OK"; //Set id counter if (basicUsersData.Length > 0) { User._Id_counter = ((basicUsersData.Last()[0] - 48) + 1); } else { User._Id_counter = 0; } //arrange using (StreamWriter sw = new StreamWriter( (cashDispenserLibraryTestSettings._SystemSettings == PlatformType.Windows) ? "cashDispenserDatabase\\BasicUsers.txt" : "cashDispenserDatabase/BasicUsers.txt", false)) { foreach (var basicUserData in basicUsersData) { sw.WriteLine(basicUserData); } } //act //Connect with database MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository( cashDispenserLibraryTestSettings._SystemSettings); try { mockBasicUsersRepository.Add(basicUser: new BasicUser( id: basicUserId, pin: new PinVAL(value: basicUserPin), name: new NameVAL(value: basicUserName), surname: new SurnameVAL(value: basicUserSurname), bankAccount: new BankAccount( state: new MoneyVAL( value: basicUserBankAccountValue, currency: basicUserBankAccountCurrency)))); } catch (MockBasicUsersRepository_Exception mbur_e) { result = mbur_e.What(); } if (result.Equals("OK")) { //Check add result BasicUser added_basicUser = null; try { if (basicUserId >= 0) { added_basicUser = mockBasicUsersRepository.Get( basicUserId: basicUserId); } else { added_basicUser = mockBasicUsersRepository.Get( basicUserId: (User._Id_counter - 1)); } } catch (MockBasicUsersRepository_Exception mbur_e) { result = mbur_e.What(); } if (result.Equals("OK")) { if ((((basicUserId >= 0) && (added_basicUser._Id != basicUserId)) || ((basicUserId < 0) && (added_basicUser._Id != (User._Id_counter - 1)))) || (!(added_basicUser._Pin._Value.Equals(basicUserPin))) || (!(added_basicUser._Name._Value.Equals(basicUserName))) || (!(added_basicUser._Surname._Value.Equals(basicUserSurname))) || (added_basicUser._BankAccount.state._Value != basicUserBankAccountValue) || (added_basicUser._BankAccount.state._Currency != basicUserBankAccountCurrency)) { result = "!!! Issue with get basic user !!!"; } } } //assert Assert.AreEqual(expected: expected, actual: result); }
private void AddBasicUserButton_Click(object sender, EventArgs e) { // Add new basic user try { // Get new basic user's informations string basicUserName = this.NameValueTextBox.Text; string basicUserSurname = this.SurnameValueTextBox.Text; string basicUserPin = this.PinValueTextBox.Text; // Connect with database MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository(SystemSettings._PlatformType); // Check pin in database if (mockBasicUsersRepository.GetAll().Any((singleBasicUser) => singleBasicUser._Pin._Value == basicUserPin) == true) { this.ErrorLabel.Show(); this.ErrorLabel.Text = "Użytkownik O Podanym Pinie Istnieje W Bazie"; throw new Exception(); } decimal basicUserAccountState = ((this.AccountStateValueTextBox.Text.Length > 0) ? decimal.Parse( this.AccountStateValueTextBox.Text.Replace(',', '.'), CultureInfo.InvariantCulture) : 0.0M); BasicUser basicUser = new BasicUser( id: -1, name: new NameVAL(value: basicUserName), pin: new PinVAL(value: basicUserPin), surname: new SurnameVAL(value: basicUserSurname), bankAccount: new BankAccount( state: new MoneyVAL(value: basicUserAccountState, currency: Currency.PLN))); // Add new basic user's record mockBasicUsersRepository.Add(basicUser: basicUser); // Show add new basic user result AdministratorAddBasicUserResultPanel administratorAddBasicUserResultPanel = new AdministratorAddBasicUserResultPanel(); administratorAddBasicUserResultPanel.ShowDialog(); this.Dispose(); } catch (NameVAL_Exception n_e) { this.ErrorLabel.Text = n_e.What(); this.ErrorLabel.Show(); } catch (SurnameVAL_Exception s_e) { this.ErrorLabel.Text = s_e.What(); this.ErrorLabel.Show(); } catch (PinVAL_Exception p_e) { this.ErrorLabel.Text = p_e.What(); this.ErrorLabel.Show(); } catch (BankAccount_Exception b_e) { this.ErrorLabel.Text = b_e.What(); this.ErrorLabel.Show(); } catch (MoneyVAL_Exception m_e) { this.ErrorLabel.Text = m_e.What(); this.ErrorLabel.Show(); } catch (Exception ex) { } }