Пример #1
0
        public void Rename_GivenNullAgency_ThrowsArgumentException()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                Agency agency = null;
                var name = new PersonNameBuilder()
                    .WithFirst("Albert")
                    .WithLast("Smith");
                var patient = new Patient(agency, name, new PatientProfileBuilder().Build());

                // Exercise
                patient.Rename(null);

                // Verify
            }
        }
Пример #2
0
        public void Rename_GivenValidName_ValidationFailureEventIsNotRaised()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                bool eventRaised = false;
                DomainEvent.Register<RuleViolationEvent> ( p => eventRaised = true );

                var agency = new Mock<Agency>();
                var name = new PersonNameBuilder()
                    .WithFirst("Albert")
                    .WithLast("Smith");
                var patient = new Patient(agency.Object, name, new PatientProfileBuilder().Build());

                var newName = new PersonNameBuilder()
                    .WithFirst("Fred")
                    .WithLast("Thomas");

                // Exercise
                patient.Rename(newName);

                // Verify
                Assert.IsFalse(eventRaised);
            }
        }
Пример #3
0
        public void Rename_GivenValidName_NameIsChanged()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var agencyMock = new Mock<Agency>();
                var name = new PersonNameBuilder()
                    .WithFirst("Albert")
                    .WithLast("Smith");
                var patient = new Patient(agencyMock.Object, name, new PatientProfileBuilder().Build());

                var newName = new PersonNameBuilder()
                    .WithFirst("Fred")
                    .WithLast("Thomas");

                // Exercise
                patient.Rename(newName);

                // Verify
                Assert.IsTrue(patient.Name == newName);
            }
        }
Пример #4
0
        public void Rename_GivenValidName_PatientRenamedEventWithCorrectInfoIsRaised()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                Patient patientArgumentInEvent = null;
                DomainEvent.Register<PatientRenamedEvent> ( p => patientArgumentInEvent = p.Patient );

                var agencyMock = new Mock<Agency>();
                var name = new PersonNameBuilder()
                    .WithFirst("Albert")
                    .WithLast("Smith");
                var patient = new Patient(agencyMock.Object, name, new PatientProfileBuilder().Build());

                var newName = new PersonNameBuilder()
                    .WithFirst("Fred")
                    .WithLast("Thomas");

                // Exercise
                patient.Rename(newName);

                // Verify
                Assert.IsTrue(ReferenceEquals(patient, patientArgumentInEvent) && patientArgumentInEvent.Name == newName);
            }
        }
Пример #5
0
        public void Rename_GivenTheSameName_PatientRenamedEventIsNotRaised()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                bool eventRaised = false;
                DomainEvent.Register<PatientRenamedEvent>(p => eventRaised = true);

                var agencyMock = new Mock<Agency>();
                var name = new PersonNameBuilder()
                    .WithFirst("Albert")
                    .WithLast("Smith");
                var patient = new Patient(agencyMock.Object, name, new PatientProfileBuilder().Build());

                // Exercise
                patient.Rename(name);

                // Verify
                Assert.IsFalse(eventRaised);
            }
        }