public void Handle_GivenValidPatientInfo_ReturnsPatientDtoThatWasSavedInDB()
        {
            var patientRepository = new PatientRepository ( SessionProvider );
            var patientFactory = new PatientFactory(patientRepository, new PatientUniqueIdentifierGenerator());
            var dtoToDomainMappingHelper = new DtoToDomainMappingHelper ( new LookupValueRepository ( SessionProvider ) );
            var handler = new CreateNewPatientRequestHandler(dtoToDomainMappingHelper, patientFactory)
                              {
                                  SessionProvider = SessionProvider
                              };

            // When you do Agatha Request Handler testing, always declare the request as the base class type Agatha.Common.Request
            Request request = new CreateNewPatientRequest
                              {
                                  AgencyKey = SafeHarborAgency.Key,
                                  BirthDate = new DateTime ( 1983, 8, 29 ),
                                  FirstName = "John",
                                  Gender = new LookupValueDto
                                               {
                                                   WellKnownName = MaleGender.WellKnownName,
                                                   Key = MaleGender.Key,
                                                   Name = MaleGender.Name
                                               },
                                  LastName = "Smith",
                                  MiddleName = "Middle"
                              };

            var response = handler.Handle ( request ) as CreateNewPatientResponse;

            Assert.IsTrue ( response.PatientDto.Key > 0 );
        }
        public void Handle_GivenInValidPatientInfo_ThrowsException()
        {
            var patientRepository = new PatientRepository ( SessionProvider );
            var patientFactory = new PatientFactory(patientRepository, new PatientUniqueIdentifierGenerator());
            var dtoToDomainMappingHelper = new DtoToDomainMappingHelper ( new LookupValueRepository ( SessionProvider ) );
            var handler = new CreateNewPatientRequestHandler ( dtoToDomainMappingHelper, patientFactory )
                              {
                                  SessionProvider = SessionProvider
                              };

            // When you do Agatha Request Handler testing, always declare the request as the base class type Agatha.Common.Request
            Request request = new CreateNewPatientRequest
                                  {
                                      AgencyKey = SafeHarborAgency.Key
                                  };
            handler.Handle ( request );
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds the new.
 /// </summary>
 protected override void AddNew()
 {
     AddNewState = AddNewState.Unknown;
     var createPatientRequest = new CreateNewPatientRequest
         {
             AgencyKey = CurrentUserContext.Agency.Key,
             FirstName = AddNewPatient.FirstName,
             LastName = AddNewPatient.LastName,
             BirthDate = AddNewPatient.BirthDate,
             Gender = AddNewPatient.Gender
         };
     var requestDispatcher = _asyncRequestDispatcherFactory.CreateAsyncRequestDispatcher ();
     requestDispatcher.Add ( createPatientRequest );
     IsLoading = true;
     requestDispatcher.ProcessRequests ( CreatePatientRequestDispatcherCompleted, HandleRequestDispatcherException );
 }