Esempio n. 1
0
        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 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);
        }