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); }
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(); }
public void Initialize() { var autoMocker = new NSubstituteAutoMocker <PatientRetriever>(); autoMocker .Get <IPatientRepository>() .GetPatientById(5) .Returns(new Patient { FirstName = "John5", LastName = "Nath5" }); //Arrange _patientRetriever = autoMocker.ClassUnderTest; }
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; }