C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,260 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Why is this unit test failing even though when I check the console it is indead printing out each of the appointment slots why is my lists empty I am using NUINT. When I inspect the first list its null appointmentsSlots.
I no the logic works here in the dotnet fiddle. https://dotnetfiddle.net/xZYQvd
[TestCase(1, 1, "Dan")]//Bike , Student 1 , Slot 1
[TestCase(1, 2, "David")]//Bike , Student 1 , Slot 2
[TestCase(2, 1, "David")]//Weights , Student 1 , Slot 1
[TestCase(2, 2, "Dan")]//Weights , Student 1 , Slot 1
public void TestAppointmentSlots(int workoutType, int studentId, string studentName)
{
List<WorkoutAppointments> workoutAppointments = new List<WorkoutAppointments>();
List<AppointmentSlot> appointmentsSlots = new List<AppointmentSlot>();
int durationOfSession = 10;
int gapBetweenSessions = 0;
DateTime start = DateTime.Today.AddHours(9).AddMinutes(30);
DateTime end = DateTime.Today.AddHours(8).AddMinutes(30);
DateTime[] datetime;
for (DateTime appointment = start; appointment < end; appointment = appointment.AddMinutes(durationOfSession + gapBetweenSessions))
{
AppointmentSlot slot = new AppointmentSlot
{
SlotType = 1,
Year = start.Year,
Hour = start.Hour,
StartDate = start,
EndDate = end,
IsActive = true,
IsDeleted = false,
IsAvailable = false,
};
appointmentsSlots.Add(slot);
Console.Write(appointment
.ToString("HH:mm"));
}
foreach (var appointment in appointmentsSlots)
{
WorkoutAppointments workoutAppointment = new WorkoutAppointments();
workoutAppointment.Id = workoutAppointment.Id + 1;
workoutAppointment.StudentId = studentId;
workoutAppointment.StudentName = studentName;
workoutAppointment.StartTime = appointment.StartDate;
workoutAppointment.EndTime = appointment.EndDate;
workoutAppointment.Year = appointment.StartDate.Year;
workoutAppointment.Hour = appointment.StartDate.Hour;
workoutAppointment.Duration = durationOfSession;
workoutAppointment.IsStudentFinishedWorkOut = false;
workoutAppointment.IsActive = true;
workoutAppointment.IsDeleted = false;
workoutAppointments.Add(workoutAppointment);
}
Assert.AreEqual(appointmentsSlots.Count, 60);
}