public void CreateStaff_NullAgency_ThrowsArgumentException() { var staffRepository = new Mock <IStaffRepository>(); var lookupValueRepository = new Mock <ILookupValueRepository>(); var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository.Object); StaffProfile staffProfile = new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("Fred").WithLast("Smith")); staffFactory.CreateStaff(null, staffProfile); }
public void CreateStaff_GivenValidArguments_CreatesAStaff() { var staffRepository = new Mock <IStaffRepository>(); var lookupValueRepository = CreateMockLookupRepository(); var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository); var agency = new Mock <Agency>(); StaffProfile staffProfile = new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("Fred").WithLast("Smith")); Staff staff = staffFactory.CreateStaff(agency.Object, staffProfile); Assert.IsNotNull(staff); }
public void CreateStaff_GivenValidArguments_StaffChecklistIsCreated() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup var staffRepository = new Mock <IStaffRepository>(); var lookupValueRepository = new LookupValueRepositoryFixture(); var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository); var agency = new Mock <Agency>(); StaffProfile staffProfile = new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("Fred").WithLast("Smith")); var staff = staffFactory.CreateStaff(agency.Object, staffProfile); AssertStaffChecklistCreation(staff, lookupValueRepository); } }
public void CreateStaff_GivenValidArguments_StaffIsMadePersistent() { bool isPersistent = false; var staffRepository = new Mock <IStaffRepository>(); var lookupValueRepository = CreateMockLookupRepository(); staffRepository.Setup(s => s.MakePersistent(It.IsAny <Staff>())).Callback(() => isPersistent = true); var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository); var agency = new Mock <Agency>(); StaffProfile staffProfile = new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("Fred").WithLast("Smith")); staffFactory.CreateStaff(agency.Object, staffProfile); Assert.IsTrue(isPersistent); }
public void CreateStaff_GivenValidArguments_StaffIsEditable() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup var staffRepository = new Mock <IStaffRepository>(); var lookupValueRepository = CreateMockLookupRepository(); var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository); var agency = new Mock <Agency>(); StaffProfile staffProfileWithoutMiddleName = new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("Fred").WithLast("Smith")); var staff = staffFactory.CreateStaff(agency.Object, staffProfileWithoutMiddleName); StaffProfile staffProfileWithMiddleName = new StaffProfileBuilder().WithStaffName( new PersonNameBuilder().WithFirst("Fred").WithLast("Smith").WithMiddle("Middle Name")); staff.ReviseStaffProfile(staffProfileWithMiddleName); } }