コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public async Task CreateAsyncShouldReturnNewDepartment()
        {
            var db = Tests.GetDatabase();
            var departmentService = new DepartmentService(db);
            await departmentService.CreateAsync("Department", "Gosho", "SomeURL");

            await db.SaveChangesAsync();

            db.Departments.Should()
            .HaveCount(1);
        }
コード例 #4
0
        public async Task FindByNameShouldReturnTrueDepartment()
        {
            var db = Tests.GetDatabase();
            var departmentService = new DepartmentService(db);
            await departmentService.CreateAsync("Department", "Gosho", "SomeURL");

            await db.SaveChangesAsync();

            var finded = await departmentService.FindByName("Department");

            finded.Should().BeOfType <Department>();
        }
コード例 #5
0
        public async Task <ActionResult <DepartmentDocument> > Create(int companyId, [FromBody] DepartmentDocument department)
        {
            var companyDto = await CompanyService.GetByIdAsync(companyId);

            if (companyDto == null)
            {
                return(NotFound($"Company with id: '{companyId}' not found"));
            }

            var createdDepartment = await DepartmentService.CreateAsync(companyId, department.ToDto());

            return(CreatedAtAction(nameof(GetById), new { id = createdDepartment.Id }, createdDepartment.ToDocument()));
        }
コード例 #6
0
        public async Task CreateAsync_ValidObjectPassed_ReturnCreatedBusiness()
        {
            // Arrange
            var department = new Department("Some name");

            _repositoryMock
            .Setup(rep => rep.AddAsync(department))
            .ReturnsAsync(department);

            // Act
            var createdDepartment = await _departmentService.CreateAsync(department);

            // Assert
            Assert.Equal(department.Name, createdDepartment.Name);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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();
        }
コード例 #9
0
        public async Task DeleteShouldReturnTrueAndProperCountOfDepartments()
        {
            var db = Tests.GetDatabase();
            var departmentService = new DepartmentService(db);
            await departmentService.CreateAsync("Department", "Gosho", "SomeURL");

            await db.SaveChangesAsync();

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

            var deleted = await departmentService.Delete(id);

            await db.SaveChangesAsync();

            deleted.Should()
            .BeTrue();

            db.Departments.Should()
            .HaveCount(0);
        }
コード例 #10
0
        public async Task HandleValidSubmit()
        {
            await _departmentService.CreateAsync(CreateDepartmentModel);

            _navigationManager.NavigateTo("department/department-list");
        }