Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public void CreateStaff_GivenValidArguments_StaffEventIsCreated()
        {
            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"));

                Staff staff = staffFactory.CreateStaff(agency.Object, staffProfile);

                AssertStaffEventCreation(staff, lookupValueRepository);
            }
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        public void DestroyStaff_GivenAStaff_StaffIsMadeTransient()
        {
            bool isTransient = false;

            var staffRepository = new Mock<IStaffRepository>();
            var lookupValueRepository = new Mock<ILookupValueRepository>();
            staffRepository.Setup(s => s.MakeTransient(It.IsAny<Staff>())).Callback(() => isTransient = true);

            var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository.Object);

            var staff = new Mock<Staff>();

            staffFactory.DestroyStaff(staff.Object);

            Assert.IsTrue(isTransient);
        }
Exemplo n.º 5
0
        public void DestroyStaff_GivenANullStaff_ThrowsArgumentException()
        {
            var staffRepository = new Mock<IStaffRepository>();
            var lookupValueRepository = new Mock<ILookupValueRepository>();
            var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository.Object);

            staffFactory.DestroyStaff(null);
        }
Exemplo n.º 6
0
        public void CreateStaff_NullLastName_ThrowsArgumentException()
        {
            var staffRepository = new Mock<IStaffRepository>();
            var lookupValueRepository = new Mock<ILookupValueRepository>();
            var staffFactory = new StaffFactory(staffRepository.Object, lookupValueRepository.Object);
            var agency = new Mock<Agency>();

            StaffProfile staffProfileWithoutLastName =
                new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("Fred"));

            staffFactory.CreateStaff(agency.Object, staffProfileWithoutLastName);
        }
Exemplo n.º 7
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);
        }