Beispiel #1
0
        public void UpdateEmployee_ShouldReturnNewEmployee()
        {
            // Fixture set-up
            var repoEmployeeStub = new EmployeeRepositoryStub(new Employee()
            {
                Id        = 1,
                Firstname = "Joe",
                Lastname  = "Bloggs",
                Phone     = "22222222",
                Email     = "*****@*****.**",
                CompanyId = 2
            });

            var sut = new EmployeeService(repoEmployeeStub, null);

            // Expected result
            var expected = EmployeeServiceTestUtility.CreateValidEmployee();

            // Exercise the SUT (system under test)
            var actual = sut.updateEmployee(
                employeeId: expected.Id,
                companyId: expected.CompanyId,
                firstName: expected.Firstname,
                lastName: expected.Lastname,
                phone: expected.Phone,
                email: expected.Email);

            // Assertion or verfication phase
            AreEmployeeEqual(expected, actual);
        }
Beispiel #2
0
        public void UpdateEmployee_ShouldThrowException()
        {
            // Fixture set-up
            var repoEmployeeStub = new EmployeeRepositoryStub(null);

            var sut = new EmployeeService(repoEmployeeStub, null);

            var expected = new Employee()
            {
                Id        = 1,
                Firstname = "John",
                Lastname  = "Smith",
                Phone     = "11111111",
                Email     = "*****@*****.**",
                CompanyId = 1
            };


            // Exercise the SUT (system under test)
            var actual = sut.updateEmployee(
                employeeId: expected.Id,
                companyId: expected.CompanyId,
                firstName: expected.Firstname,
                lastName: expected.Lastname,
                phone: expected.Phone,
                email: expected.Email);

            // Assertion or verfication phase
            Assert.IsNull(actual);
        }
 public void Initialize()
 {
     _mainViewModel = new MainViewModel();
     _employee = new Employee {Login = "******"};
     _employees = new List<Employee> {_employee};
     _repository = new EmployeeRepositoryStub(_employees);
     SettingsHelper.SaveConnectionString("Data Source=YOGER-SUPERMAN\\SQLEXPRESS;Initial Catalog=HolidayCalendar;Integrated Security=True;Connect Timeout=5");
 }
 public void Initialize()
 {
     _authenticatorStub = new DirectoryAuthenticatorStub(_domain, _userName, _password);
     _mainViewModel = new MainViewModel();
     _employees = new List<Employee>();
     _employeeRepository = new EmployeeRepositoryStub(_employees);
     _viewModel = GetNewViewModel();
     _passwordBox = new PasswordBox {Password = _password};
     SettingsHelper.ResetSettings();
 }
 public void Initialize()
 {
     _employees = new List<Employee>
     {
         new Employee(),
         new Employee(),
         new Employee()
     };
     _employeeRepository = new EmployeeRepositoryStub(_employees);
     _generator = new EmployeeCalendarGenerator(_employeeRepository, new Calendar(), new MainViewModel());
     SettingsHelper.SaveConnectionString("Data Source=YOGER-SUPERMAN\\SQLEXPRESS;Initial Catalog=HolidayCalendar;Integrated Security=True;Connect Timeout=5");
 }