Beispiel #1
0
        public void GetAllPatientDentists_WithValidIdAndNoDentists_ShouldReturnEmptyDentistCollection()
        {
            var options = new DbContextOptionsBuilder <DentHubContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())  // Give a Unique name to the DB
                          .Options;
            var dbContext   = new DentHubContext(options);
            var appointment = new Appointment
            {
                PatientId = "1",
                DentistID = "1"
            };
            var appointment2 = new Appointment
            {
                PatientId = "1",
                DentistID = "2",
            };
            var appointment3 = new Appointment
            {
                PatientId = "1",
                DentistID = "2",
            };
            var dentist1 = new DentHubUser
            {
                Id          = "1",
                SpecialtyId = 1,
                Email       = "*****@*****.**",
                FirstName   = "Test",
                LastName    = "LastName",
                IsActive    = true,
                PhoneNumber = "1234",
                UserName    = "******",
            };
            var dentist2 = new DentHubUser
            {
                Id          = "2",
                SpecialtyId = 2,
                Email       = "*****@*****.**",
                FirstName   = "Test2",
                LastName    = "LastName2",
                IsActive    = true,
                PhoneNumber = "123456",
                UserName    = "******",
            };

            dbContext.Appointments.Add(appointment);
            dbContext.Appointments.Add(appointment2);
            dbContext.Appointments.Add(appointment3);
            dbContext.DentHubUsers.Add(dentist1);
            dbContext.DentHubUsers.Add(dentist2);
            dbContext.SaveChanges();

            var userRepository        = new DbRepository <DentHubUser>(dbContext);
            var appointmentRepository = new DbRepository <Appointment>(dbContext);
            var ratingRepository      = new DbRepository <Rating>(dbContext);
            var appointmentService    = new AppointmentService(appointmentRepository, ratingRepository);
            var service = new DentistService(userRepository, appointmentService);
            var result  = service.GetAllPatientDentists("5");

            Assert.Empty(result);
        }
Beispiel #2
0
        public void GetAllActiveDentists_WithValidDentists_ShouldReturnDentistsCollection()
        {
            var options = new DbContextOptionsBuilder <DentHubContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())  // Give a Unique name to the DB
                          .Options;
            var dbContext = new DentHubContext(options);

            var dentist = new DentHubUser
            {
                Id          = "1",
                IsActive    = true,
                FirstName   = "Dentist 1",
                LastName    = "Test",
                SpecialtyId = 1,
            };

            var dentist2 = new DentHubUser
            {
                Id          = "2",
                IsActive    = true,
                FirstName   = "Dentist 2",
                LastName    = "Test2",
                SpecialtyId = 2,
            };

            var dentist3 = new DentHubUser
            {
                Id          = "3",
                IsActive    = false,
                FirstName   = "Dentist 3",
                LastName    = "Test3",
                SpecialtyId = 3,
            };

            var dentist4 = new DentHubUser
            {
                Id          = "4",
                IsActive    = true,
                FirstName   = "Dentist 4",
                LastName    = "Test4",
                SpecialtyId = 44,
            };

            dbContext.DentHubUsers.Add(dentist);
            dbContext.DentHubUsers.Add(dentist2);
            dbContext.DentHubUsers.Add(dentist3);
            dbContext.DentHubUsers.Add(dentist4);
            dbContext.SaveChanges();

            var userRepository        = new DbRepository <DentHubUser>(dbContext);
            var appointmentRepository = new DbRepository <Appointment>(dbContext);
            var ratingRepository      = new DbRepository <Rating>(dbContext);
            var appointmentService    = new AppointmentService(appointmentRepository, ratingRepository);
            var service = new DentistService(userRepository, appointmentService);
            var result  = service.GetAllActiveDentists();

            Assert.Equal(new DentHubUser[] { dentist, dentist2, dentist4 }, result);
        }
Beispiel #3
0
        public void GetPatientById_WithEmptyPatientSet_ShouldReturnException()
        {
            var options = new DbContextOptionsBuilder <DentHubContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())  // Give a Unique name to the DB
                          .Options;
            var dbContext = new DentHubContext(options);

            var userRepository        = new DbRepository <DentHubUser>(dbContext);
            var appointmentRepository = new DbRepository <Appointment>(dbContext);
            var ratingRepository      = new DbRepository <Rating>(dbContext);
            var appointmentService    = new AppointmentService(appointmentRepository, ratingRepository);
            var service = new DentistService(userRepository, appointmentService);

            Assert.Throws <ArgumentException>(() => service.GetDentistById("7"));
        }
Beispiel #4
0
        public async Task GetDentistById_WithValidIdAndNoSpecialty_ShouldReturnException()
        {
            var options = new DbContextOptionsBuilder <DentHubContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())  // Give a Unique name to the DB
                          .Options;
            var dbContext = new DentHubContext(options);
            var dentist   = new DentHubUser
            {
                Id          = "20",
                SpecialtyId = 1,
                Email       = "*****@*****.**",
                FirstName   = "Test",
                LastName    = "LastName",
                IsActive    = false,
                PhoneNumber = "1234",
                UserName    = "******",
            };
            var dentist2 = new DentHubUser
            {
                Id          = "21",
                Specialty   = null,
                Email       = "*****@*****.**",
                FirstName   = "Test2",
                LastName    = "LastName2",
                IsActive    = true,
                PhoneNumber = "123456",
                UserName    = "******",
            };

            dbContext.DentHubUsers.Add(dentist);
            dbContext.DentHubUsers.Add(dentist2);
            await dbContext.SaveChangesAsync();

            var userRepository        = new DbRepository <DentHubUser>(dbContext);
            var appointmentRepository = new DbRepository <Appointment>(dbContext);
            var ratingRepository      = new DbRepository <Rating>(dbContext);
            var appointmentService    = new AppointmentService(appointmentRepository, ratingRepository);
            var service = new DentistService(userRepository, appointmentService);

            Assert.Throws <ArgumentException>(() => service.GetDentistById("21"));
        }
Beispiel #5
0
        public DentistsViewModel()
        {
            this.dentistService = new DentistService();

            var databaseDentists = this.dentistService.GetAllDentists();

            this.Dentists = new ObservableCollection <Dentist>(databaseDentists);

            this.DeleteDentist = new RelayCommand(this.HandleDeleteDentist);

            this.NavigateToAddDentist = new RelayCommand(this.HandleNavigateToAddDentist);

            this.NavToHome          = new RelayCommand(this.HandleNavToHome);
            this.NavToPatients      = new RelayCommand(this.HandleNavToPatients);
            this.NavToDentists      = new RelayCommand(this.HandleNavToDentists);
            this.NavToOrders        = new RelayCommand(this.HandleNavToOrders);
            this.NavToAnnualReport  = new RelayCommand(this.HandleNavToAnnualReport);
            this.NavToMonthlyReport = new RelayCommand(this.HandleNavToMonthlyReport);

            this.DisplayDentist = new RelayCommand(this.HandleDisplayDentist);
        }
Beispiel #6
0
 public CaseController(CaseService caseService, PatientService patientService, DentistService dentistService)
 {
     _caseService    = caseService;
     _patientService = patientService;
     _dentistService = dentistService;
 }
 public DentistController(DentistService dentistService)
 {
     _dentistService = dentistService;
 }