Exemplo n.º 1
0
        public void GivenPatientWhenRegisteringThenPersistToDb()
        {
            HospitalManagementSystemContext HospitalManagementSystemContext = EntityFrameworkMock.Create <HospitalManagementSystemContext>();

            TypeFactory.RegisterInstance(HospitalManagementSystemContext);

            Patient patient = new Patient();

            patient.PersonId         = 1;
            patient.Person.Id        = 1;
            patient.Person.FirstName = "Vusi";
            patient.Person.Surname   = "Khoza";
            patient.Person.IdNumber  = "1234";

            IPatientRepository   patientRepository   = new PatientRepository();
            IPatientRegistration patientRegistration = new PatientRegistration(patientRepository);

            patientRegistration.Register(patient);

            IPatientRetriever patientRetriever = new PatientRetriever(patientRepository);

            patientRetriever.Retrieve(patient.Person.IdNumber);

            Assert.IsNotNull(patientRetriever.Patient);
            Assert.AreEqual(patient.Person.Id, patientRetriever.Patient.Person.Id);
            Assert.AreEqual(patient.Person.FirstName, patientRetriever.Patient.Person.FirstName);
            Assert.AreEqual(patient.Person.Surname, patientRetriever.Patient.Person.Surname);
        }
Exemplo n.º 2
0
        public void it_should_throw_an_exception()
        {
            var logger            = Substitute.For <ILogger>();
            var patientRepository = Substitute.For <IPatientRepository>();

            //Arrange
            var patientRetriever = new PatientRetriever(logger, patientRepository);
            var patientDto       = patientRetriever.Retrieve(0);

            patientDto.Should().BeNull();
        }
Exemplo n.º 3
0
        public void Initialize()
        {
            var autoMocker = new NSubstituteAutoMocker <PatientRetriever>();

            autoMocker
            .Get <IPatientRepository>()
            .GetPatientById(5)
            .Returns(new Patient
            {
                FirstName = "John5",
                LastName  = "Nath5"
            });

            //Arrange
            _patientRetriever = autoMocker.ClassUnderTest;
        }
Exemplo n.º 4
0
        public void Initialize()
        {
            var autoMocker = new NSubstituteAutoMocker <PatientRetriever>();

            autoMocker
            .Get <IPatientRepository>()
            .GetPatientById(1)
            .Returns(new Patient
            {
                FirstName   = "John1",
                LastName    = "Nath1",
                MiddleName  = "K1",
                DateOfBirth = DateTime.Parse("1971-01-01")
            });

            //Arrange
            _patientRetriever = autoMocker.ClassUnderTest;
        }