public async Task DeleteShouldReturnTrueAndProperCountOfDoctors()
        {
            var db                = Tests.GetDatabase();
            var doctorService     = new DoctorService(db, null);
            var departmentService = new DepartmentService(db);
            await departmentService.CreateAsync("Cardiology", "Gosho", "SomeURL");

            await db.SaveChangesAsync();

            await doctorService.CreateAsync(
                "Gosho", "*****@*****.**", "SomeURL", "Cardiologist", "Cardiology");

            await db.SaveChangesAsync();

            var id = await db.Doctors
                     .Where(d => d.Name == "Gosho")
                     .Select(d => d.Id)
                     .FirstOrDefaultAsync();

            var deleted = await doctorService.Delete(id);

            await db.SaveChangesAsync();

            deleted.Should()
            .BeTrue();

            db.Doctors.Should()
            .HaveCount(1);
        }
        public async Task CreateShouldReturnTrueAndNewPatient()
        {
            var db                = Tests.GetDatabase();
            var doctorService     = new DoctorService(db, null);
            var departmentService = new DepartmentService(db);
            await departmentService.CreateAsync("Cardiology", "Gosho", "SomeURL");

            await db.SaveChangesAsync();

            await doctorService.CreateAsync(
                "Gosho", "*****@*****.**", "SomeURL", "Cardiologist", "Cardiology");

            await db.SaveChangesAsync();

            var patientService = new PatientService(db);
            var result         = await patientService.Create("Patient",
                                                             "8698969896",
                                                             28, "*****@*****.**");

            await db.SaveChangesAsync();

            result.Should()
            .BeTrue();

            db.Patients.Should()
            .HaveCount(1);
        }
        public async Task CreateAsyncShouldReturnTrueAndNewDoctor()
        {
            var db                = Tests.GetDatabase();
            var doctorService     = new DoctorService(db, null);
            var departmentService = new DepartmentService(db);
            await departmentService.CreateAsync("Cardiology", "Gosho", "SomeURL");

            await db.SaveChangesAsync();

            await doctorService.CreateAsync(
                "Gosho", "*****@*****.**", "SomeURL", "Cardiologist", "Cardiology");

            await db.SaveChangesAsync();

            db.Doctors.Should()
            .HaveCount(1);
        }
Esempio n. 4
0
        public async Task CreateAsync_DoctorValidationSucceed_CreatesStreet()
        {
            // Arrange
            var doctor   = new DoctorUpdateModel();
            var expected = new Doctor();

            var doctorDAL = new Mock <IDoctorDAL>();

            doctorDAL.Setup(x => x.InsertAsync(doctor)).ReturnsAsync(expected);

            var doctorService = new DoctorService(doctorDAL.Object);

            // Act
            var result = await doctorService.CreateAsync(doctor);

            // Assert
            result.Should().Be(expected);
        }
        public async Task EditShouldReturnTrueAndEditedPatient()
        {
            var db                = Tests.GetDatabase();
            var doctorService     = new DoctorService(db, null);
            var departmentService = new DepartmentService(db);
            await departmentService.CreateAsync("Cardiology", "Gosho", "SomeURL");

            await db.SaveChangesAsync();

            await doctorService.CreateAsync(
                "Gosho", "*****@*****.**", "SomeURL", "Cardiologist", "Cardiology");

            await db.SaveChangesAsync();

            var patientService = new PatientService(db);
            var result         = await patientService.Create("Patient",
                                                             "8698969896",
                                                             28, "*****@*****.**");

            await db.SaveChangesAsync();

            var id = await db.Patients
                     .Where(d => d.Name == "Patient")
                     .Select(d => d.Id)
                     .FirstOrDefaultAsync();

            var edited = await patientService
                         .Edit(id, "PatientEdited",
                               "8698969896",
                               28, "*****@*****.**");

            edited.Should()
            .BeTrue();

            db.Patients.Should()
            .HaveCount(1);

            result.Should()
            .BeTrue();
        }