Unit test always returning an empty list on Nunit yet has console output

NOVATROOP77 256 Reputation points
2021-09-29T20:31:00.523+00:00

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);
}
C#
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
Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
329 questions
{count} votes