Exemplo n.º 1
0
        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");
            }
        }
Exemplo n.º 2
0
        public void CreatePatientDocument_GivenValidArguments_IsMadePersistent()
        {
            bool isPersistent   = false;
            var  bytes          = new byte[] { 0, 0, 0 };
            var  hashingUtility = new Mock <IHashingUtility>();

            hashingUtility.Setup(m => m.ComputeHash(bytes)).Returns("XXXXXXXXXXX");


            var patientDocumentRepositoryMock = new Mock <IPatientDocumentRepository> ();

            patientDocumentRepositoryMock
            .Setup(p => p.MakePersistent(It.IsAny <PatientDocument> ()))
            .Callback(() => isPersistent = true);
            var patientDocumentFactory = new PatientDocumentFactory(
                patientDocumentRepositoryMock.Object, hashingUtility.Object);
            var patient             = new Mock <Patient> ();
            var patientDocumentType = new Mock <PatientDocumentType> ();


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

            Assert.IsTrue(isPersistent);
        }
Exemplo n.º 3
0
        public void CreatePatientDocument_NullPatient_ThrowsException()
        {
            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 patientDocumentType = new Mock <PatientDocumentType> ();

            patientDocumentFactory.CreatePatientDocument(
                null,
                patientDocumentType.Object,
                bytes,
                "filename");
        }
Exemplo n.º 4
0
        public void DestroyPatientDocument_GivenPatientDocument_Succeeds()
        {
            var bytes          = new byte[] { 0, 0, 0 };
            var hashingUtility = new Mock <IHashingUtility>();

            hashingUtility.Setup(m => m.ComputeHash(It.IsAny <byte[]>())).Returns("XXXXXXXXXXX");


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

            var patientDocument = new Mock <PatientDocument> ();

            patientDocument.Setup(p => p.Patient).Returns(patient.Object);

            patientDocumentFactory.DestroyPatientDocument(patientDocument.Object);
        }
Exemplo n.º 5
0
        public void CreatePatientDocument_GivenValidArguments_Succeeds()
        {
            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> ();


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

            Assert.IsNotNull(patientDocument);
        }
Exemplo n.º 6
0
        public void DestroyPatientDocument_GivenPatientDocument_MadeTransient()
        {
            bool madeTransient  = true;
            var  hashingUtility = new Mock <IHashingUtility>();

            hashingUtility.Setup(m => m.ComputeHash(It.IsAny <byte[]>())).Returns("XXXXXXXXXXX");

            var patientDocumentRepositoryMock = new Mock <IPatientDocumentRepository> ();

            patientDocumentRepositoryMock
            .Setup(p => p.MakeTransient(It.IsAny <PatientDocument> ()))
            .Callback(() => madeTransient = true);
            var patientDocumentFactory = new PatientDocumentFactory(
                patientDocumentRepositoryMock.Object, hashingUtility.Object);
            var patient = new Mock <Patient> ();

            var patientDocument = new Mock <PatientDocument> ();

            patientDocument.Setup(p => p.Patient).Returns(patient.Object);

            patientDocumentFactory.DestroyPatientDocument(patientDocument.Object);

            Assert.IsTrue(madeTransient);
        }