public void SynchronizePatientAccount_GivenPatientWithoutExistingBillingOffice_ThrowsArgumentException()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                var fixture = new Fixture ().Customize ( new AutoMoqCustomization () );

                var billingOfficeRepository = new Mock<IBillingOfficeRepository> ();
                billingOfficeRepository.Setup ( p => p.GetByAgencyKey ( It.IsAny<long> () ) ).Returns ( () => null );
                fixture.Register ( () => billingOfficeRepository.Object );

                var agencyProfile = fixture.CreateAnonymous<AgencyProfile> ();

                var agency = new Mock<Agency> ();
                agency.SetupGet(p => p.Key).Returns(fixture.CreateAnonymous<long>());
                agency.SetupGet ( p => p.AgencyProfile ).Returns ( agencyProfile );

                var patient = new Mock<Patient> ();
                patient.SetupGet(p => p.Key).Returns(fixture.CreateAnonymous<long>());
                patient.SetupGet ( p => p.Agency ).Returns ( agency.Object );

                var patientAccountSynchronizationService = fixture.CreateAnonymous<PatientAccountSynchronizationService> ();

                // Exercise
                patientAccountSynchronizationService.SynchronizePatientAccount ( patient.Object );

                // Verify
            }
        }
        public void CreatePatient_GivenPatientProfileWithNullBirthDate_PatientCreatedEventIsNotRaised()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

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

                var patientRepositoryMock = new Mock<IPatientRepository>();

                var agency = new Mock<Agency>();

                var patientUniqueIdentifierCalculatorMock = new Mock<IPatientUniqueIdentifierGenerator>();
                var patientFactory = new PatientFactory(
                    patientRepositoryMock.Object, patientUniqueIdentifierCalculatorMock.Object);

                // Exercise
                patientFactory.CreatePatient(agency.Object, CreateValidName(), InvalidPatientProfileWithNullBirthDate());

                // Verify
                Assert.IsFalse(eventRaised);
            }
        }
        public void CreatePatientDocument_GivenValidArguments_EntityIsEditable()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var bytes = new byte[] {0, 0, 0};
                var patientDocumentRepositoryMock = new Mock<IPatientDocumentRepository>();
                var hashingUtility = new Mock<IHashingUtility>();
                hashingUtility.Setup(m => m.ComputeHash(bytes)).Returns("XXXXXXXXXXX");

                var patientDocumentFactory = new PatientDocumentFactory(
                    patientDocumentRepositoryMock.Object, hashingUtility.Object);
                var patient = new Mock<Patient>();
                var patientDocumentType = new Mock<PatientDocumentType>();

                PatientDocument patientDocument = patientDocumentFactory.CreatePatientDocument(
                    patient.Object,
                    patientDocumentType.Object,
                    bytes,
                    "filename");

                patientDocument.ReviseOtherDocumentTypeName ( "Other"  );
            }
        }
        public void CreatePatient_GivenPatientProfileWithNullBirthDate_PatientIsNotMadePersistent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var isPersistent = false;

                var patientRepositoryMock = new Mock<IPatientRepository>();
                patientRepositoryMock
                    .Setup(p => p.MakePersistent(It.IsAny<Patient>()))
                    .Callback(() => isPersistent = true);
                var agency = new Mock<Agency>();

                var patientUniqueIdentifierCalculatorMock = new Mock<IPatientUniqueIdentifierGenerator>();
                var patientFactory = new PatientFactory(
                    patientRepositoryMock.Object, patientUniqueIdentifierCalculatorMock.Object);

                // Exercise
                patientFactory.CreatePatient(agency.Object, CreateValidName(), InvalidPatientProfileWithNullBirthDate());

                // Verify
                Assert.IsFalse(isPersistent);
            }
        }
        public void CreateLabSpecimen_GivenValidArguments_LabSpecimenIsEditable()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                var activityType = new Mock<ActivityType>();
                var lookupValueRepository = new Mock<ILookupValueRepository>();
                lookupValueRepository
                    .Setup(l => l.GetLookupByWellKnownName<ActivityType>(It.IsAny<string>()))
                    .Returns(activityType.Object);

                var labSpecimenRepository = new Mock<ILabSpecimenRepository>();

                var labSpecimenFactory = new LabSpecimenFactory(
                    labSpecimenRepository.Object,
                    lookupValueRepository.Object);

                var visit = new Mock<Visit>();
                var clinicalCase = new Mock<ClinicalCase>();
                var patient = new Mock<Patient>();
                var labSpecimenType = new Mock<LabSpecimenType>();

                visit.Setup(v => v.ClinicalCase).Returns(clinicalCase.Object);
                clinicalCase.Setup(c => c.Patient).Returns(patient.Object);

                var labSpecimen = labSpecimenFactory.CreateLabSpecimen(visit.Object);
                labSpecimen.ReviseLabSpecimenType ( labSpecimenType.Object );
            }
        }
        public void CreateVitalSign_GivenValidArguments_VitalSignIsEditable()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                var activityType = new Mock<ActivityType>();
                var lookupValueRepository = new Mock<ILookupValueRepository>();
                lookupValueRepository
                    .Setup(l => l.GetLookupByWellKnownName<ActivityType>(It.IsAny<string>()))
                    .Returns(activityType.Object);

                var vitalSignRepository = new Mock<IVitalSignRepository>();

                var vitalSignFactory = new VitalSignFactory(
                    vitalSignRepository.Object,
                    lookupValueRepository.Object);

                var visit = new Mock<Visit>();
                var clinicalCase = new Mock<ClinicalCase>();
                var patient = new Mock<Patient>();

                visit.Setup(v => v.ClinicalCase).Returns(clinicalCase.Object);
                clinicalCase.Setup(c => c.Patient).Returns(patient.Object);

                var vitalSign = vitalSignFactory.CreateVitalSign(visit.Object);

                vitalSign.ReviseHeight ( new Height ( 100, null ) );
            }
        }
 public void CreateAllergy_GivenValidArguments_AllergyIsEditable()
 {
     using (var serviceLocatorFixture = new ServiceLocatorFixture())
     {
         var allergy = CreateAllergyByAllergyFactory();
         allergy.ReviseAllergySeverityType ( new AllergySeverityType() );
     }
 }
        public void CreateSocialHistory_GivenValidArguments_SocialHistoryIsEditable()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var entity = _factory.CreateSocialHistory(_visit.Object);

                var smokingStatus =
                    _lookupValueRepository.Object.GetLookupByWellKnownName<SmokingStatus>(It.IsAny<string>());
                var socialHistorySmoking = new SocialHistorySmoking(smokingStatus);
                entity.ReviseSocialHistorySmoking(socialHistorySmoking);
            }
        }
        public void CreatePatientContact_GivenValidArguments_CreatesContact()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture ( serviceLocatorFixture );
                var patientContactRepository = new Mock<IPatientContactRepository> ();
                var patientContactFactory = new PatientContactFactory ( patientContactRepository.Object );

                var patient = new Mock<Patient> ();

                PatientContact patientContact = patientContactFactory.CreatePatientContact ( patient.Object, "Fred", "Smith" );

                Assert.IsNotNull ( patientContact );
            }
        }
        public void CreateLocation_GivenValidArguments_CreatesALocation()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var locationRepository = new Mock<ILocationRepository>();
                var locationFactory = new LocationFactory(locationRepository.Object);
                var agency = new Mock<Agency>();

                var location = locationFactory.CreateLocation(
                    agency.Object, new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName(LegalName)));

                Assert.IsNotNull(location);
            }
        }
        public void CreateMedication_GivenValidArguments_MedicationIsEditable()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                var mediationRepository = new Mock<IMedicationRepository>();
                var medicationFactory = new MedicationFactory(
                    mediationRepository.Object);

                var patient = new Mock<Patient>();

                var medicationCode = new CodedConceptBuilder().WithCodedConceptCode("TheCode");
                var medication = medicationFactory.CreateMedication(patient.Object, medicationCode, medicationCode);

                medication.ReviseInstructionsNote ( "some instruction" );
            }
        }
        public void CreatePatientContact_GivenValidArguments_ContactIsEditable()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var patientContactRepository = new Mock<IPatientContactRepository>();
                var patientContactFactory = new PatientContactFactory(
                    patientContactRepository.Object);

                var patient = new Mock<Patient>();

                PatientContact patientContact = patientContactFactory.CreatePatientContact(
                    patient.Object, "Fred", "Smith");

                patientContact.ReviseNote("some note");
            }
        }
        public void CreateAppointment_GivenValidArguments_AppointmentIsEditable()
        {
            using ( var serviceLocatorFixture = new ServiceLocatorFixture () )
            {
                // Setup
                var appointmentRepository = new Mock<IAppointmentRepository> ();
                var appointmentFactory = new AppointmentFactory (
                    appointmentRepository.Object );

                var staff = new Mock<Staff> ();
                var start = new DateTime ( 2000, 1, 1, 9, 0, 0 );
                var end = new DateTime ( 2000, 1, 1, 10, 0, 0 );

                Appointment appointment = appointmentFactory.CreateAppointment ( staff.Object, new DateTimeRange ( start, end ) );

                appointment.ReviseSubjectDescription ( "Some Appointment" );
            }
        }
        public void CreateLocation_GivenValidArguments_LocationIsEditable()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var locationRepository = new Mock<ILocationRepository>();
                var locationFactory = new LocationFactory(locationRepository.Object);
                var agency = new Mock<Agency>();

                var location = locationFactory.CreateLocation(
                    agency.Object,
                        new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName(LegalName)));

                location.ReviseLocationProfile(
                    new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName("Some Name").Build()).Build());
            }
        }
        public void CreatePatientContact_GivenValidArguments_ContactIsPersistent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture ( serviceLocatorFixture );
                bool isPersistent = false;

                var patientContactRepository = new Mock<IPatientContactRepository> ();
                patientContactRepository.Setup ( p => p.MakePersistent ( It.IsAny<PatientContact> () ) ).Callback ( () => isPersistent = true );
                var patientContactFactory = new PatientContactFactory ( patientContactRepository.Object );

                var patient = new Mock<Patient> ();

                patientContactFactory.CreatePatientContact ( patient.Object, "Fred", "Smith" );

                Assert.IsTrue ( isPersistent );
            }
        }
Exemple #16
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
            }
        }
Exemple #17
0
        public void ReviseAgencyProfile_LegalNameChangeSuccessful()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                //Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                const string newName = "ADifferentName";
                var agencyType = new Mock<AgencyType>();
                Agency agency =
                    new AgencyBuilder().WithAgencyProfile(
                        new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName("SomeName")));

                agency.ReviseAgencyProfile(
                    new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(
                        new AgencyNameBuilder().WithLegalName(newName)));

                Assert.AreEqual(agency.AgencyProfile.AgencyName.LegalName, newName);
            }
        }
        public void CreateLocation_GivenValidArguments_LocationIsMadePersistent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var isPersistent = false;

                var locationRepository = new Mock<ILocationRepository>();
                locationRepository.Setup(l => l.MakePersistent(It.IsAny<Location>())).Callback(() => isPersistent = true);

                var locationFactory = new LocationFactory(locationRepository.Object);
                var agency = new Mock<Agency>();

                locationFactory.CreateLocation(
                    agency.Object, new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName(LegalName)));

                Assert.IsTrue(isPersistent);
            }
        }
Exemple #19
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);
            }
        }
        public void CreatePatient_GivenPatientProfileWithNullBirthDate_PatientIsNotCreated()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var agency = new Mock<Agency>();
                var patientRepositoryMock = new Mock<IPatientRepository>();
                var patientUniqueIdentifierCalculatorMock = new Mock<IPatientUniqueIdentifierGenerator>();
                var patientFactory = new PatientFactory(
                    patientRepositoryMock.Object, patientUniqueIdentifierCalculatorMock.Object);

                // Exercise
                var patient = patientFactory.CreatePatient(agency.Object, CreateValidName(), InvalidPatientProfileWithNullBirthDate());

                // Verify
                Assert.IsNull(patient);
            }
        }
Exemple #21
0
        public void CreateVisit_GivenValidArguments_VisitIsEditable()
        {
            using ( var serviceLocatorFixture = new ServiceLocatorFixture () )
            {
                // Setup
                var visitRepository = new Mock<IVisitRepository> ();
                var visitStatus = new Mock<VisitStatus> ();
                visitStatus.SetupProperty ( v => v.WellKnownName, WellKnownNames.VisitModule.VisitStatus.Scheduled );
                var visitStatusRepository = new Mock<IVisitStatusRepository> ();
                visitStatusRepository
                    .Setup ( v => v.GetByWellKnownName ( WellKnownNames.VisitModule.VisitStatus.Scheduled ) )
                    .Returns ( visitStatus.Object );

                var visitFactory = new VisitFactory (
                    visitRepository.Object,
                    visitStatusRepository.Object );

                var patient = new Mock<Patient> ();

                var clinicalCase = new Mock<ClinicalCase> ();
                clinicalCase.Setup ( c => c.Patient ).Returns ( patient.Object );

                var agency = new Mock<Agency>();
                var visitTemplate = new VisitTemplate(agency.Object, "Initial Behavioral Health - Adult", "99204" );

                var initialLocation = new Mock<Location> ();

                var staff = new Mock<Staff> ();
                var appointmentDateTimeRange = new DateTimeRange ( new DateTime (), new DateTime () );

                var visit = visitFactory.CreateVisit (
                    staff.Object,
                    appointmentDateTimeRange,
                    clinicalCase.Object,
                    visitTemplate,
                    initialLocation.Object );

                visit.ReviseNote ( "note" );
            }
        }
Exemple #22
0
        public static void SetupServiceLocatorFixture(ServiceLocatorFixture serviceLocatorFixture)
        {
            serviceLocatorFixture.StructureMapContainer.Configure(
                c =>
                    {
                        c.For<IDomainEventService>().Use(new DomainEventService());
                    });

            serviceLocatorFixture.StructureMapContainer.Configure(
                c => c.Scan(x =>
                {
                    // in the scan operation, include all needed dlls (Rem.*)
                    // be cautious in the future - this could still pick up unwanted assemblies,
                    // such as the stray test project that mistakenly ends up in the bin folder.
                    // so consider those possibilities if errors pop up, and you're led here.
                    x.AssembliesFromApplicationBaseDirectory(p => (p.FullName == null) ? false : p.FullName.Contains("Rem."));

                    x.ConnectImplementationsToTypesClosing(typeof(IRuleCollection<>));

                    x.ConnectImplementationsToTypesClosing(typeof(IRuleCollectionCustomizer<,>));
                }));
        }
Exemple #23
0
        public void CreateAgency_WithValidArguments_AgencyIsEditable()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var agencyRepository = new Mock<IAgencyRepository>();
                var agencyFactory = new AgencyFactory(agencyRepository.Object);
                var agencyType = new Mock<AgencyType>();

                AgencyProfile agencyProfileWithoutDisplayName =
                    new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(new AgencyNameBuilder().WithLegalName(LegalName));

                var agency = agencyFactory.CreateAgency(agencyProfileWithoutDisplayName);

                AgencyProfile agencyProfileWithDisplayName =
                    new AgencyProfileBuilder().WithAgencyType(agencyType.Object).WithAgencyName(
                        new AgencyNameBuilder().WithLegalName(LegalName).WithDisplayName("My Agency Display Name"));

                agency.ReviseAgencyProfile(agencyProfileWithDisplayName);
            }
        }
        public void SynchronizePatientAccount_GivenPatient_RevisePayorCoveragesForPatientAccountCorrectly()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                var fixture = new Fixture().Customize(new AutoMoqCustomization());

                var billingPayorCoverages = new List<PayorCoverage> ();

                var payorCoverageTranslator = new Mock<IPayorCoverageTranslator>();
                payorCoverageTranslator.Setup(p => p.Translate(It.IsAny<IList<PayorCoverageCache>>())).Returns(billingPayorCoverages);
                fixture.Register(() => payorCoverageTranslator);

                var patientAccount = new Mock<PatientAccount>();
                patientAccount.SetupGet(p => p.Key).Returns(fixture.CreateAnonymous<long>());
                var patientAccountRepository = new Mock<IPatientAccountRepository>();
                patientAccountRepository.Setup(p => p.GetByMedicalRecordNumber(It.IsAny<long>())).Returns(() => patientAccount.Object);
                fixture.Register(() => patientAccountRepository.Object);

                var agency = new Mock<Agency>();
                agency.SetupGet(p => p.Key).Returns(fixture.CreateAnonymous<long>());

                var patient = new Mock<Patient>();
                patient.SetupGet(p => p.Key).Returns(fixture.CreateAnonymous<long>());
                patient.SetupGet(p => p.Agency).Returns(agency.Object);

                var patientPhoneNumbers = fixture.CreateMany<PatientPhone>();
                patient.SetupGet(p => p.PhoneNumbers).Returns(patientPhoneNumbers);

                var patientAccountSynchronizationService = fixture.CreateAnonymous<PatientAccountSynchronizationService>();

                // Exercise
                patientAccountSynchronizationService.SynchronizePatientAccount(patient.Object);

                // Verify
                patientAccount.Verify(p => p.RevisePayorCoverages(billingPayorCoverages));
            }
        }
Exemple #25
0
        public void SetPrimaryLocation_GivenLocationButWithoutAgencyLocations_ValidationFailureEventIsRaised()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);
                var staff = new Staff(new Mock<Agency>().Object,
                          new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("first name").WithLast("last name")));

                var location = new Location(
                    new Mock<Agency>().Object,
                    new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName("location name")));

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

                // Exercise
                staff.SetPrimaryLocation(location);

                // Verify
                Assert.IsTrue(eventRaised);
            }
        }
Exemple #26
0
        public void SetPrimaryLocation_GivenLocationButWithoutAgencyLocations_PrimaryLocationIsNotChanged()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture ( serviceLocatorFixture );

                var staff = new Staff(new Mock<Agency>().Object,
                        new StaffProfileBuilder().WithStaffName(new PersonNameBuilder().WithFirst("first name").WithLast("last name")));

                var location = new Location(
                    new Mock<Agency>().Object,
                    new LocationProfileBuilder().WithLocationName(new LocationNameBuilder().WithName("location name")));

                staff.SetPrimaryLocation(null);

                // Exercise
                staff.SetPrimaryLocation(location);

                // Verify
                Assert.IsTrue ( staff.PrimaryLocation == null );
            }
        }
Exemple #27
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);
            }
        }
        public void CreateSystemPermission_CannotGrantSystemPermissionToTaskGroup_ValidationFailureEventIsRaised()
        {
            using ( var serviceLocatorFixture = new ServiceLocatorFixture () )
            {
                // Setup
                SetupServiceLocatorFixture ( serviceLocatorFixture );

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

                var systemRoleRepositoryMock = new Mock<ISystemRoleRepository> ();
                var systemRoleFactory = new SystemRoleFactory ( systemRoleRepositoryMock.Object );

                // Exercise
                var systemRole = systemRoleFactory.CreateSystemRole ( "RoleName", "Role description.", SystemRoleType.TaskGroup );

                var systemPermission = new SystemPermission ( "WellKnownName", "MyPermission", "My permission description." );
                systemRole.GrantSystemPermission ( systemPermission );

                // Verify
                Assert.IsTrue ( eventRaised );
            }
        }
Exemple #29
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);
            }
        }
Exemple #30
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);
            }
        }