public void GetDate_WithFormAnswers_ReturnCorrectDate() { var formAnswers = new FormAnswers { Pages = new List <PageAnswers> { new PageAnswers { Answers = new List <Answers> { new Answers { QuestionId = "test-date", Response = "01/01/2020" } } } } }; var result = DatePicker.GetDate(formAnswers, "test-date"); Assert.True(result.HasValue); Assert.True(result.Value == new DateTime(2020, 1, 1)); }
public void GetDate_ReturnNull_IfKeyNotPresent() { var viewModel = new Dictionary <string, dynamic>(); DateTime?result = DatePicker.GetDate(viewModel, "test-date"); Assert.False(result.HasValue); }
/** * \brief <b>Brief Description</b> - Execute <b><i>class method</i></b> - Entry point into the reconcile month menu * \details <b>Details</b> * * This takes in the scheduling, demographics and billing libraries * * \return <b>void</b> */ public void Execute(Scheduling scheduling, Demographics demographics, Billing billing) { // display a clear screen Container.DisplayContent(new List <Pair <string, string> >() { { new Pair <string, string>("", "") } }, 1, 1, MenuCodes.BILLING, "Billing", Description); // get the month to generate the report for DateTime getMonth = DatePicker.GetDate(scheduling, DateTime.Today, false); // check if the user didnt cancel the month selection if (getMonth.Ticks != 0) { // format the name of the text file string date = string.Format("{0}{1}govFile.txt", getMonth.Year, getMonth.Month); // generate the report for the reconciled month List <string> report = billing.ReconcileMonthlyBilling(date); // display the success message Container.DisplayContent(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("Report successfully generated!", "") }, 1, -1, MenuCodes.BILLING, "Billing", Description); // wait for confirmation from user that they read the message Console.ReadKey(); } }
/** * \brief <b>Brief Description</b> - Execute <b><i>class method</i></b> - An overload of the entry point into the reconcile summary viewing menu * \details <b>Details</b> * * This takes in the existing patient information, if it should return a patient and the demographics library * * \return <b>void</b> */ public void Execute(Scheduling scheduling, Demographics demographics, Billing billing) { Container.DisplayContent(new List <Pair <string, string> >() { { new Pair <string, string>("", "") } }, 2, 1, MenuCodes.BILLING, "Billing", Description); // let the user pick a month DateTime getMonth = DatePicker.GetDate(scheduling, DateTime.Today, false); // check if user did not cancel during month selection screen if (getMonth.Ticks != 0) { // generate the government file name string date = string.Format("{0}{1}govFile.txt", getMonth.Year, getMonth.Month); // get the list of the report contents List <string> report = billing.ReconcileMonthlyBilling(date); List <Pair <string, string> > content = new List <Pair <string, string> >(); // create the content using the lines in the report foreach (string line in report) { content.Add(new Pair <string, string>(line, "")); } // display the contents of the report Container.DisplayContent(content, 2, -1, MenuCodes.BILLING, "Billing", Description); Console.ReadKey(); } }
/** * \brief <b>Brief Description</b> - Execute <b><i>class method</i></b> - Entry point into the generate monthly report menu * \details <b>Details</b> * * This takes in the scheduling, demographics and billing libraries * * \return <b>void</b> */ public void Execute(Scheduling scheduling, Demographics demographics, Billing billing) { // display a clear screen Container.DisplayContent(new List <Pair <string, string> >() { { new Pair <string, string>("", "") } }, 0, -1, MenuCodes.BILLING, "Billing", Description); // get the month to generate the report for DateTime getMonth = DatePicker.GetDate(scheduling, DateTime.Today, false); // check if the user didnt cancel the month selection if (getMonth.Ticks != 0) { // check if the report generation was successful if (billing.GenerateMonthlyBillingFile(scheduling, demographics, getMonth.Year, getMonth.Month)) { Container.DisplayContent(new List <Pair <string, string> >() { { new Pair <string, string>("Report successfuly generated!", "") } }, 0, -1, MenuCodes.BILLING, "Billing", Description); } else { Container.DisplayContent(new List <Pair <string, string> >() { { new Pair <string, string>("Report failed to generate.", "") } }, 0, -1, MenuCodes.BILLING, "Billing", Description); } // wait for confirmation from user that they read the message Console.ReadKey(); } }
public void GetDate_ShouldThrowException_IfDateIsIncorrectlyFormatted() { var viewModel = new Dictionary <string, dynamic>() { { "test-date", "ABC123" } }; Assert.Throws <FormatException>(() => DatePicker.GetDate(viewModel, "test-date")); }
public void GetDate_ReturnNull_IfKeyPresentButValueIsEmpty() { var viewModel = new Dictionary <string, dynamic> { { "test-date", "" } }; DateTime?result = DatePicker.GetDate(viewModel, "test-date"); Assert.False(result.HasValue); }
public void GetDate_ReturnCorrectDate() { var viewModel = new Dictionary <string, dynamic>() { { "test-date", "01/01/2020" } }; var result = DatePicker.GetDate(viewModel, "test-date"); Assert.True(result.HasValue); Assert.True(result.Value == new DateTime(2020, 1, 1)); }
public ValidationResult Validate(Element element, Dictionary <string, dynamic> viewModel, FormSchema baseForm) { if ((!element.Type.Equals(EElementType.DatePicker) && !element.Type.Equals(EElementType.DateInput)) || string.IsNullOrEmpty(element.Properties.IsDateBeforeAbsolute)) { return(new ValidationResult { IsValid = true }); } DateTime?dateValue = new DateTime(); if (element.Type.Equals(EElementType.DatePicker)) { dateValue = DatePicker.GetDate(viewModel, element.Properties.QuestionId); } if (element.Type.Equals(EElementType.DateInput)) { dateValue = DateInput.GetDate(viewModel, element.Properties.QuestionId); } if (!dateValue.HasValue) { return new ValidationResult { IsValid = true } } ; if (!DateTime.TryParse(element.Properties.IsDateBeforeAbsolute, out DateTime comparisonDateValue)) { throw new FormatException("IsDateBeforeAbsoluteValidator: The comparison date format was incorrect"); } if (dateValue < comparisonDateValue) { return new ValidationResult { IsValid = true } } ; return(new ValidationResult { IsValid = false, Message = !string.IsNullOrEmpty(element.Properties.IsDateBeforeValidationMessage) ? element.Properties.IsDateBeforeValidationMessage : string.Format(ValidationConstants.IS_DATE_BEFORE_VALIDATOR_DEFAULT, element.Properties.IsDateBeforeAbsolute) }); } } }
public void GetDate_WithFormAnswers_ShouldReturnNull_IfAnswersIsNotPresent() { var formAnswers = new FormAnswers { Pages = new List <PageAnswers> { new PageAnswers { Answers = new List <Answers>() } } }; Assert.False(DatePicker.GetDate(formAnswers, "test-date").HasValue); }
public void GetDate_WithFormAnswers_ShouldReturnNull_IfAnswersPresent_AndEmpty() { var formAnswers = new FormAnswers { Pages = new List <PageAnswers> { new PageAnswers { Answers = new List <Answers> { new Answers { QuestionId = "test-date" } } } } }; Assert.False(DatePicker.GetDate(formAnswers, "test-date").HasValue); }
public void GetDate_WithFormAnswers_ShouldThrowException_IfDateIsIncorrectlyFormatted() { var formAnswers = new FormAnswers { Pages = new List <PageAnswers> { new PageAnswers { Answers = new List <Answers> { new Answers { QuestionId = "test-date", Response = "ABC123" } } } } }; Assert.Throws <FormatException>(() => DatePicker.GetDate(formAnswers, "test-date")); }
/** * \brief <b>Brief Description</b> - Get <b><i>class method</i></b> - main method used by outside methods to get the appointment * \details <b>Details</b> * * This takes in the scheduling and demographics libraries * * \return <b>Pair<Day, int></b> - the appointment slot */ public static Pair <Day, int> Get(Scheduling scheduling, Demographics demographics) { Console.CursorVisible = true; Container.DisplayContent(new List <KeyValuePair <string, string> >(), 0, -1, MenuCodes.SCHEDULING, "Scheduling", Description); DateTime date = DateTime.Today; while (true) { // get the month from the user date = DatePicker.GetDate(scheduling, date, false); // check if the user didnt cancel the date selection if (date != new DateTime(0)) { do { // get the day from the user DateTime selectedDate = DatePicker.GetDate(scheduling, date, true); // check if the user canceled the date selection if (selectedDate == new DateTime(0)) { break; } // get the selected day Day selectedDay = scheduling.GetScheduleByDay(selectedDate); // get a list of appointments on that day List <Appointment> apptList = selectedDay.GetAppointments(); List <Pair <string, string> > apptContent = new List <Pair <string, string> >(); // loop through all appointments on that day foreach (Appointment appointment in apptList) { string line = ""; // if the appointment slot is not taken, sets it to be displayed as (EMPTY) if (appointment.AppointmentID == -1 && appointment.PatientID == -1) { line = "(EMPTY)"; } else { // get information about the main patient Patient mainPatient = demographics.GetPatientByID(appointment.PatientID); // get information about the dependant of the main patient Patient dependantPatient = demographics.GetPatientByID(appointment.DependantID); // format the main patient information line = string.Format("{0}, {1} - {2}", mainPatient.LastName, mainPatient.FirstName, mainPatient.HCN); // if the patient has a dependant, adds it to the patient information line if (dependantPatient != null) { line += string.Format(" > {0}, {1} - {2}", dependantPatient.LastName, dependantPatient.FirstName, dependantPatient.HCN); } } // adds the patient line to the appointment content that will be displayed apptContent.Add(new Pair <string, string>(line, "")); } int selectedIndex = 1; // display all appointments Container.DisplayContent(apptContent, 0, selectedIndex, MenuCodes.SCHEDULING, "Scheduling", Description); ConsoleKey keyPressed = new ConsoleKey(); Console.CursorVisible = false; // loop until user cancels do { keyPressed = Console.ReadKey(true).Key; switch (keyPressed) { // down arrow pressed therefore go to appt below case ConsoleKey.DownArrow: if (selectedIndex < apptContent.Count) { selectedIndex++; } break; // up arrow pressed therefore go to appt above case ConsoleKey.UpArrow: if (selectedIndex > 1) { selectedIndex--; } break; // enter pressed therefore return the selected appointment case ConsoleKey.Enter: return(new Pair <Day, int>(selectedDay, selectedIndex - 1)); } // re-display the appointment selection Container.DisplayContent(apptContent, 0, selectedIndex, MenuCodes.SCHEDULING, "Scheduling", Description); } while (keyPressed != ConsoleKey.Escape); } while (true); } // exit because user canceled date selection else { break; } } // user canceled therefore return a blank selection return(new Pair <Day, int>(null, -1)); }