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 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); } }
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 CreatePatient_GivenValidParameters_PatientIsMadePersistent2() { using (var serviceLocatorFixture = new ServiceLocatorFixture()) { // Setup SetupServiceLocatorFixture(serviceLocatorFixture); string uniqueIdentifier = "unique identifier"; var patientRepositoryMock = new Mock<IPatientRepository>(); var agency = new Mock<Agency>(); var patientUniqueIdentifierCalculatorMock = new Mock<IPatientUniqueIdentifierGenerator>(); patientUniqueIdentifierCalculatorMock .Setup ( p => p.GenerateUniqueIdentifier( It.IsAny<Patient> () ) ) .Returns(() => uniqueIdentifier); var patientFactory = new PatientFactory( patientRepositoryMock.Object, patientUniqueIdentifierCalculatorMock.Object); // Exercise var patient = patientFactory.CreatePatient(agency.Object, CreateValidName(), ValidPatientProfile()); // Verify Assert.AreSame(uniqueIdentifier, patient.UniqueIdentifier, "Patient uniqueIdentifier is not assigned correctly."); } }