コード例 #1
0
ファイル: PatientTests.cs プロジェクト: divyang4481/REM
        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
        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 );
        }