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

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

                var agencyMock = new Mock<Agency>();
                var name = new PersonNameBuilder()
                    .WithFirst("Albert")
                    .WithLast("Smith");

                var address = new AddressBuilder ()
                    .WithFirstStreetAddress ( "123 Test Street" )
                    .WithCityName ( "Testville" )
                    .WithStateProvince ( new StateProvince () )
                    .WithPostalCode ( new PostalCode ( "12345" ) )
                    .Build ();

                var patientAddress = new PatientAddressBuilder ()
                    .WithPatientAddressType ( new PatientAddressType () )
                    .WithAddress(address)
                    .Build ();

                var patient = new Patient(agencyMock.Object, name, new PatientProfileBuilder().Build());
                patient.AddAddress ( patientAddress );

                // Exercise
                patient.AddAddress(patientAddress);

                // Verify
                Assert.IsTrue(eventRaised);
            }
        }
Пример #2
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
            }
        }
Пример #3
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);
            }
        }
Пример #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_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);
            }
        }
Пример #6
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);
            }
        }
        private void BuildTaddYoungPatient()
        {
            PersonName name = new PersonNameBuilder ()
                .WithFirst ( "Tadd" )
                .WithLast ( "Young" )
                .Build ();
            PatientProfile profile = new PatientProfileBuilder ()
                .WithBirthDate ( DateTime.Parse ( "5/10/2000" ) )
                .WithPatientGender ( MaleGender )
                .Build ();
            TaddYoungPatient = new Patient ( SafeHarborAgency, name, profile );
            TaddYoungPatient.UpdateUniqueIdentifier("taddyoung");

            TaddYoungPatient.AddPhoneNumber ( new PatientPhone ( HomePatientPhoneType, "555-255-5454" ) );

            var patientRace = new PatientRace ( WhiteRace );
            TaddYoungPatient.AddPatientRace ( patientRace );
            TaddYoungPatient.SetPrimaryRace ( WhiteRace );

            TaddYoungPatient.AddAlias ( new PatientAlias ( NicknamePatientAliasType, "Tadd" ) );

            TaddYoungPatient.AddPatientDisability ( new PatientDisability ( DeafDisability ) );

            Session.SaveOrUpdate ( TaddYoungPatient );
        }
        private void BuildAlbertSmithPatient()
        {
            PersonName name = new PersonNameBuilder ()
                .WithFirst ( "Albert" )
                .WithLast ( "Smith" )
                .Build ();
            PatientProfile profile = new PatientProfileBuilder ()
                .WithBirthDate ( DateTime.Parse ( "5/10/1971" ) )
                .WithPatientGender ( MaleGender )
                .Build ();
            AlbertSmithPatient = new Patient ( SafeHarborAgency, name, profile );
            AlbertSmithPatient.UpdateUniqueIdentifier("albertsmith");

            var address = new AddressBuilder ()
                .WithFirstStreetAddress ( "14235 South St" )
                .WithCityName ( "Baltimore" )
                .WithPostalCode ( new PostalCode ( "21075" ) )
                .WithStateProvince ( MarylandStateProvince )
                .Build ();

            PatientAddress albertSmithAddress = new PatientAddressBuilder ()
                .WithPatientAddressType ( HomePatientAddressType )
                .WithAddress(address)
                .Build ();

            AlbertSmithPatient.AddAddress ( albertSmithAddress );

            AlbertSmithPatient.AddPhoneNumber ( new PatientPhone ( HomePatientPhoneType, "555-255-5454" ) );

            var patientRace = new PatientRace ( WhiteRace );
            AlbertSmithPatient.AddPatientRace ( patientRace );
            AlbertSmithPatient.SetPrimaryRace(WhiteRace);

            AlbertSmithPatient.AddAlias ( new PatientAlias ( NicknamePatientAliasType, "Al-bear" ) );

            AlbertSmithPatient.AddPatientDisability ( new PatientDisability ( DeafDisability ) );

            Session.SaveOrUpdate ( AlbertSmithPatient );
        }