예제 #1
0
        public void CreatePatientContact_NullFirstName_ThrowsArgumentException()
        {
            var patientContactRepository = new Mock<IPatientContactRepository> ();
            var patientContactFactory = new PatientContactFactory (
                patientContactRepository.Object );

            var patient = new Mock<Patient> ();

            patientContactFactory.CreatePatientContact ( patient.Object, null, "Smith" );
        }
예제 #2
0
        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 );
            }
        }
예제 #3
0
        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");
            }
        }
예제 #4
0
        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 );
            }
        }
예제 #5
0
        public void DestroyPatientContact_GivenAPatientContact_ContactIsTransient()
        {
            bool isTransient = false;

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

            var patient = new Mock<Patient> ();
            var patientContact = new Mock<PatientContact> ();
            patientContact.Setup ( p => p.Patient ).Returns ( patient.Object );

            patientContactFactory.DestroyPatientContact ( patientContact.Object );

            Assert.IsTrue ( isTransient );
        }
예제 #6
0
        public void DestroyPatientContact_GivenANullPatientContact_ThrowsArgumentException()
        {
            var patientContactRepository = new Mock<IPatientContactRepository> ();
            var patientContactFactory = new PatientContactFactory (
                patientContactRepository.Object );

            patientContactFactory.DestroyPatientContact ( null );
        }
예제 #7
0
        public void CreatePatientContact_NullPatient_ThrowsArgumentException()
        {
            var patientContactRepository = new Mock<IPatientContactRepository> ();
            var patientContactFactory = new PatientContactFactory (
                patientContactRepository.Object );

            patientContactFactory.CreatePatientContact ( null, "Fred", "Smith" );
        }