예제 #1
0
        private void NewTechButton_Click(object sender, RoutedEventArgs e)
        {
            // Sanity Check
            if (Utility.TextHasNoData(TechAddressTextBox))
            {
                MessageBox.Show("Input Address");
                return;
            }
            else if (Utility.TextHasNoData(TechEmailTextBox))
            {
                MessageBox.Show("Input Email");
                return;
            }
            else if (Utility.TextHasNoData(TechNameTextBox))
            {
                MessageBox.Show("Input Name");
                return;
            }
            else if (TechPasswordPasswordBox.Password == null || TechPasswordPasswordBox.Password.Trim() == "")
            {
                MessageBox.Show("Input Password");
                return;
            }
            else if (Utility.TextHasNoData(TechUsernameTextBox))
            {
                MessageBox.Show("Input Username");
                return;
            }

            // Create tech and add him
            Technician technician = new Technician
            {
                TechnicianUsername = TechUsernameTextBox.Text,
                TechnicianAddress  = TechAddressTextBox.Text,
                TechnicianEmail    = TechEmailTextBox.Text,
                TechnicianName     = TechNameTextBox.Text
            };

            TechnicianManager.AddTechnician(technician, TechPasswordPasswordBox.Password);


            (new MainWindow()).Show();
            this.Close();
        }
        public void GetTechnicianByIdTest()
        {
            // arrange
            const int    idTechnician = 1;
            const string firstname    = "Jan";
            const string surname      = "Kowalski";
            const int    salary       = 2000;

            Technician technician = new Technician(idTechnician, firstname, surname, salary);

            TechnicianManager technicianManager = new TechnicianManager();

            technicianManager.AddTechnician(technician);

            // act
            Technician obtainedTechnician = technicianManager.GetTechnicianById(idTechnician);

            // assert
            Assert.AreEqual(technician, obtainedTechnician);
        }
        public void AddTechnicianTest()
        {
            // arrange
            const int    idTechnician = 1;
            const string firstname    = "Jan";
            const string surname      = "Kowalski";
            const int    salary       = 2000;

            Technician technician = new Technician(idTechnician, firstname, surname, salary);

            TechnicianManager technicianManager = new TechnicianManager();

            // act
            technicianManager.AddTechnician(technician);

            // assert
            Technician addedTechnician = technicianManager.technicians.Last();

            Assert.AreEqual(technician, addedTechnician);
        }
        public void GetAllTest()
        {
            // arrange
            const int    idTechnician = 1;
            const string firstname    = "Jan";
            const string surname      = "Kowalski";
            const int    salary       = 2000;

            Technician technician = new Technician(idTechnician, firstname, surname, salary);

            TechnicianManager technicianManager = new TechnicianManager();

            technicianManager.AddTechnician(technician);

            List <Technician> expectedCollection = technicianManager.technicians;

            // act
            List <Technician> allTechnicians = technicianManager.GetAllTechnicians();

            // assert
            CollectionAssert.AreEquivalent(expectedCollection, allTechnicians);
        }
        public void UpdateTechnicianSalaryCheck()
        {
            // arrange
            const int    idTechnician = 1;
            const string firstname    = "Jan";
            const string surname      = "Kowalski";
            const int    salary       = 2000;

            const int newSalary = 2500;

            Technician technician = new Technician(idTechnician, firstname, surname, salary);

            TechnicianManager technicianManager = new TechnicianManager();

            technicianManager.AddTechnician(technician);

            // act
            technicianManager.UpdateTechnicianSalary(technician, newSalary);

            // assert
            Technician updatedTechnician = technicianManager.technicians.Find(c => c.IdTechnician == idTechnician);

            Assert.AreEqual(newSalary, updatedTechnician.Salary);
        }