Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
            }
        }