예제 #1
0
        public void AddPatientTest()
        {
            var mockSetPatients = new Mock <DbSet <Patient> >();

            var mockContext = new Mock <SurgeryModelContainer>();

            mockContext.Setup(m => m.Patients).Returns(mockSetPatients.Object);

            var service = new DBModels(mockContext.Object);

            service.AddPatient("Kamil", "Opalach", "111111111", "22222222222", new Address());

            mockSetPatients.Verify(m => m.Add(It.IsAny <Patient>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
예제 #2
0
        public void AddEditandDeletePatientTest()
        {
            Patient patient = new Patient
            {
                Name        = "ExampleName",
                Surname     = "ExampleSurname",
                PESELNumber = "00000000000",
                PhoneNumber = "000000000",
                Address     = new Address
                {
                    City         = "ExampleCity",
                    Country      = "ExampleCountry",
                    HomeNumber   = 0,
                    Street       = "ExampleStreet",
                    StreetNumber = 0
                }
            };

            SurgeryModelContainer smc = new SurgeryModelContainer();
            IDBModels             dbm = new DBModels(smc);

            int beforeAddPatientsCount = smc.Patients.Count();

            dbm.AddPatient(patient.Name, patient.Surname, patient.PhoneNumber, patient.PESELNumber, patient.Address);
            int afterAddPatientsCount = smc.Patients.Count();

            dbm.EditPatient(patient.PESELNumber, patient.Name, "EditedSurname", patient.PhoneNumber, patient.PESELNumber, patient.Address);
            var editedPatient          = dbm.ListPatientsByPESEL("00000000000", 0, 10);
            int numberOfEditedPatients = editedPatient.Count;

            dbm.DeletePatient("00000000000");
            int afterDeletePatientsNumber = smc.Patients.Count();

            Assert.AreEqual(afterAddPatientsCount, beforeAddPatientsCount + 1);
            Assert.AreEqual(afterAddPatientsCount, afterDeletePatientsNumber + 1);
            Assert.AreEqual("EditedSurname", editedPatient[0].Surname);
        }