Exemplo n.º 1
0
        public async Task AddEmployee_InvalidEmployeePassed_ReturnsBadRequest()
        {
            var employee = new AddEmployeeDto()
            {
                FirstName = "Jonas",
                LastName  = "Mant"
            };

            _controller.ModelState.AddModelError("Gender", "Required");

            var badResponse = await _controller.AddEmployee(employee);

            Assert.That(badResponse.Result, Is.TypeOf(typeof(BadRequestObjectResult)));
        }
Exemplo n.º 2
0
        public void Task_insertdata_Return_OkResult()
        {
            //Arrange

            var testdata = new EmployeeModel
            {
                FirstName = "Rohan", LastName = "Mmar", MobNo = "9122460175", Email = "*****@*****.**", Address = "patna", Department = "IT", Salary = 6111
            };


            //Act
            var data = employeesController.AddEmployee(testdata);

            //Assert
            Assert.IsType <OkObjectResult>(data);
        }
Exemplo n.º 3
0
        public async Task test_AddEmployee()
        {
            _fakeCommands.CallsTo(r => r.AddEmployee(new Employee())).WithAnyArguments().Returns(true);

            var result = await _controller.AddEmployee(new Employee());

            _fakeCommands.CallsTo(r => r.AddEmployee(new Employee())).WithAnyArguments().MustHaveHappened();
            Assert.True(result?.Value);
        }
Exemplo n.º 4
0
        public async Task TestForAddEmployeeFailureBy()
        {
            var context             = CreateContextForSQLite();
            var testEmployeeContext = await GetTestEmployees(context);

            var      controller = new EmployeesController(testEmployeeContext);
            Employee employee   = new Employee {
                Name = "Aksha", Id = 1114, Salary = 50000
            };

            controller.AddEmployee(employee);
            Assert.NotEqual(await testEmployeeContext.Employees.FindAsync(1114), employee);
        }
Exemplo n.º 5
0
        public async Task TestForAddEmployee()
        {
            var context             = CreateContextForSQLite();
            var testEmployeeContext = await GetTestEmployees(context);

            var      controller = new EmployeesController(testEmployeeContext);
            Employee employee   = new Employee {
                Name = "Akshay", Age = 22, Id = 1111, Salary = 50000
            };
            var result = controller.AddEmployee(employee);

            Assert.Equal(await testEmployeeContext.Employees.FindAsync(1111), employee);
        }
Exemplo n.º 6
0
        private void Button_register_Click(object sender, EventArgs e)
        {
            if (button_register.Text.Equals("ADD"))
            {
                foreach (TextBox box in textBoxes)
                {
                    if (box.Text.Trim().Equals(""))
                    {
                        MessageBox.Show("Please do not leave any empty fields.");
                        return;
                    }
                }

                currentEmployee = new Employee(controller.GetRoleId(comboBox_role.Text), textbox_name.Text, textbox_surname.Text, Char.Parse(comboBox_gender.Text.Substring(0, 1)),
                                               Int32.Parse(textbox_age.Text), textbox_email.Text, long.Parse(textbox_phone_number.Text), textbox_address.Text,
                                               DateTime.Parse(date_birth.Text), DateTime.Parse(date_joined.Text));
                controller.AddEmployee(currentEmployee);

                MessageBox.Show("Employee " + currentEmployee.Name + " registered.");

                EmployeeChanged(comboBox.Items.Count);
            }
            else
            {
                Employee currentEmployee = controller.GetEmployee(int.Parse(comboBox.Text.Split(' ')[0]));
                Employee newEmployee     = new Employee(controller.GetRoleId(comboBox_role.Text), textbox_name.Text, textbox_surname.Text, Char.Parse(comboBox_gender.Text.Substring(0, 1)),
                                                        Int32.Parse(textbox_age.Text), textbox_email.Text, long.Parse(textbox_phone_number.Text), textbox_address.Text,
                                                        DateTime.Parse(date_birth.Text), DateTime.Parse(date_joined.Text));

                if (currentEmployee.GetDifferences(newEmployee).Equals(""))
                {
                    MessageBox.Show("Nothing has changed.");
                    return;
                }

                controller.ChangeEmployee(currentEmployee, newEmployee);

                MessageBox.Show("Employee " + currentEmployee.Name + " changed.");

                EmployeeChanged(comboBox.SelectedIndex);
            }
        }