コード例 #1
0
        public NewPatientToSheduleViewModel(HospitalShedule hospitalShedule, Action sucessAction = null, Action failureAction = null)
        {
            Done = new ActionCommand(() =>
            {
                if (string.IsNullOrEmpty(Name) ||
                    string.IsNullOrEmpty(Surname) ||
                    string.IsNullOrEmpty(PassportCode) ||
                    Doctor is null)
                {
                    if (failureAction != null)
                    {
                        failureAction();
                        return;
                    }

                    throw new Exception("fields must be not empty");
                }

                var p = new Patient()
                {
                    Name         = Name,
                    PassportCode = PassportCode,
                    Surname      = Surname
                };
                hospitalShedule.AddOrCreatePatientToDoctor(p, Doctor, Date);

                sucessAction?.Invoke();
            });
        }
コード例 #2
0
        public void Done_WhenDataValid()
        {
            var shed        = new List <WPFRoman.Models.DoctorsShedule>();
            var hospContext = FakeHospitalContext.Create(
                new List <WPFRoman.Models.Doctor>(),
                shed,
                new List <WPFRoman.Models.Patient>());
            var mHospitalDb = new Mock <HospitalDb>();

            mHospitalDb.Setup(_ => _.Hospital).Returns(hospContext.Object);
            var hospitalShedule = new HospitalShedule(mHospitalDb.Object);
            var viewModel       = new NewPatientToSheduleViewModel(hospitalShedule)
            {
                Date         = default(DateTime),
                Doctor       = new WPFRoman.Models.Doctor(),
                Name         = "it is not empty string",
                PassportCode = "some code",
                Surname      = "some surname"
            };

            viewModel.Done.Execute(new object());

            Assert.AreEqual(1, shed.Count);
            //hospContext.Verify(e => e.Patients, Times.Once());
            //hospContext.Verify(e => e.DoctorsShedules, Times.Once());
        }
コード例 #3
0
        public void AddOrCreatePatientToDoctor_DoctorIsNull_Valid()
        {
            var      patient         = new Patient();
            DateTime date            = default(DateTime);
            var      hospitalShedule = new HospitalShedule(hospitalDb.Object);

            hospitalShedule.AddOrCreatePatientToDoctor(patient, null, date);

            Assert.AreEqual(1, shedule.Count);
        }
コード例 #4
0
        public AddPatientWindow(ReadOnlyObservableCollection <Doctor> doctors, HospitalShedule shedule)
        {
            Doctors             = doctors;
            NewPatientToShedule = new NewPatientToSheduleViewModel(
                shedule,
                () => MessageBox.Show("Done", "Sucess", button: MessageBoxButton.OK),
                () => MessageBox.Show("You need to write smth down", "Failure", button: MessageBoxButton.OK));

            this.DataContext = this;

            InitializeComponent();

            MonthlyCalendar.SelectedDate = DateTime.UtcNow;
        }
コード例 #5
0
        public void Done_WhenDataIsEmpty_Exeption()
        {
            var hospContext = FakeHospitalContext.Create(
                new List <WPFRoman.Models.Doctor>(),
                new List <WPFRoman.Models.DoctorsShedule>(),
                new List <WPFRoman.Models.Patient>());
            var mHospitalDb = new Mock <HospitalDb>();

            mHospitalDb.Setup(_ => _.Hospital).Returns(hospContext.Object);
            var hospitalShedule = new HospitalShedule(mHospitalDb.Object);
            var viewModel       = new NewPatientToSheduleViewModel(hospitalShedule);

            Assert.Catch(() => viewModel.Done.Execute(new object()));
        }