public void CreateMedication_NullMedicationCode_ThrowsArgumentException()
        {
            var mediationRepository = new Mock<IMedicationRepository> ();
            var medicationFactory = new MedicationFactory (
                mediationRepository.Object );

            var patient = new Mock<Patient> ();
            var provenance = new Mock<Provenance> ();

            medicationFactory.CreateMedication ( patient.Object, null, provenance.Object );
        }
        public void CreateMedication_GivenValidArguments_Succeeds()
        {
            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 );

            Assert.IsNotNull ( medication );
        }
        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 CreateMedication_GivenValidArguments_MedicationMadePersistent()
        {
            var isPersistent = false;

            var mediationRepository = new Mock<IMedicationRepository> ();
            mediationRepository
                .Setup ( m => m.MakePersistent ( It.IsAny<Medication> () ) )
                .Callback ( () => isPersistent = true );
            var medicationFactory = new MedicationFactory (
                mediationRepository.Object );

            var patient = new Mock<Patient> ();

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

            Assert.IsTrue ( isPersistent );
        }
        public void DestroyMedication_GivenAMedication_MedicationMadeTransient()
        {
            var isTransient = false;

            var mediationRepository = new Mock<IMedicationRepository> ();
            mediationRepository
                .Setup ( m => m.MakeTransient ( It.IsAny<Medication> () ) )
                .Callback ( () => isTransient = true );
            var medicationFactory = new MedicationFactory (
                mediationRepository.Object );
            var medication = new Mock<Medication> ();
            var patient = new Mock<Patient> ();
            medication.Setup ( m => m.Patient ).Returns ( patient.Object );

            medicationFactory.DestroyMedication ( medication.Object );

            Assert.IsTrue ( isTransient );
        }
        public void CreateMedication_NullPatient_ThrowsArgumentException()
        {
            var mediationRepository = new Mock<IMedicationRepository> ();
            var medicationFactory = new MedicationFactory (
                mediationRepository.Object );

            var medicationCode = new Mock<CodedConcept> ();
            medicationFactory.CreateMedication ( null, medicationCode.Object, medicationCode.Object );
        }