예제 #1
0
        public void Given_has_contact_detail_found_When_UpdateEmergencyContact_Then_calls_correct_method()
        {
            // Given
            var emergencyContactDetailParameters = new EmergencyContactDetailParameters
            {
                EmergencyContactId = 1L
            };

            var userForAuditing = new UserForAuditing();
            var target = new Employee();

            var employeeEmergencyContactDetail = new Mock<EmployeeEmergencyContactDetail>();
            employeeEmergencyContactDetail
                .Setup(x => x.Id)
                .Returns(1);

            employeeEmergencyContactDetail
                .Setup(x => x.Update(emergencyContactDetailParameters, userForAuditing));

            target.EmergencyContactDetails.Add(employeeEmergencyContactDetail.Object);

            // When
            target.UpdateEmergencyContact(emergencyContactDetailParameters, userForAuditing);

            // Then
            employeeEmergencyContactDetail.Verify(x => x.Update(emergencyContactDetailParameters, userForAuditing));
        }
예제 #2
0
        public void Given_no_contact_detail_found_When_UpdateEmergencyContact_Then_throws_exception()
        {
            // Given
            var contactDetailsParameters = new EmergencyContactDetailParameters()
            {
                EmergencyContactId = 1L
            };

            var userForAuditing = new UserForAuditing();

            var target = new Employee
            {
                EmergencyContactDetails = new List<EmployeeEmergencyContactDetail>
                                                    {
                                                        new EmployeeEmergencyContactDetail
                                                            {
                                                                Id=888
                                                            }
                                                    }
            };

            // When

            // Then
            Assert.Throws<AttemptingToUpdateEmergencyContactEmergencyContactsDetailsNotFoundForEmployeeException>(() => target.UpdateEmergencyContact(contactDetailsParameters, userForAuditing));
        }