Skip to content

Commit

Permalink
test: Initialize missing properties
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDave1999 committed Feb 27, 2024
1 parent 5303905 commit 75a2946
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 26 deletions.
120 changes: 107 additions & 13 deletions tests/UnitTests/Core/Appointments/CancelAppointmentsUseCaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,33 @@ public async Task ExecuteAsync_WhenAllAppointmentsCanBeCancelled_ShouldReturnsRe
// Arrange
var request = new CancelAppointmentsRequest
{
Reason = "Reason",
Appointments = new List<CancelAppointmentsRequest.Appointment>
{
new () { AppointmentId = 1, AppointmentDate = new DateTime(2022, 08, 02), StartHour = new TimeSpan(14, 0, 0) },
new () { AppointmentId = 2, AppointmentDate = new DateTime(2022, 08, 02), StartHour = new TimeSpan(15, 0, 0) },
new () { AppointmentId = 3, AppointmentDate = new DateTime(2022, 08, 02), StartHour = new TimeSpan(13, 0, 0) }
new()
{
AppointmentId = 1,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 02),
StartHour = new TimeSpan(14, 0, 0)
},
new()
{
AppointmentId = 2,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 02),
StartHour = new TimeSpan(15, 0, 0)
},
new()
{
AppointmentId = 3,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 02),
StartHour = new TimeSpan(13, 0, 0)
}
}
};
var claims = new Claim[]
Expand Down Expand Up @@ -56,13 +78,49 @@ public async Task ExecuteAsync_WhenSomeAppointmentsCannotBeCancelled_ShouldRetur
var expectedMessage = new AppointmentThatHasAlreadyPassedEmployeeError(pastAppointments).Message;
var request = new CancelAppointmentsRequest
{
Reason = "Reason",
Appointments = new List<CancelAppointmentsRequest.Appointment>
{
new () { AppointmentId = 1, AppointmentDate = new DateTime(2022, 08, 02), StartHour = new TimeSpan(14, 0, 0) },
new () { AppointmentId = 2, AppointmentDate = new DateTime(2022, 08, 02), StartHour = new TimeSpan(15, 0, 0) },
new () { AppointmentId = 3, AppointmentDate = new DateTime(2022, 08, 02), StartHour = new TimeSpan(08, 0, 0) },
new () { AppointmentId = 4, AppointmentDate = new DateTime(2022, 08, 01), StartHour = new TimeSpan(09, 0, 0) },
new () { AppointmentId = 5, AppointmentDate = new DateTime(2022, 08, 01), StartHour = new TimeSpan(13, 0, 0) }
new()
{
AppointmentId = 1,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 02),
StartHour = new TimeSpan(14, 0, 0)
},
new()
{
AppointmentId = 2,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 02),
StartHour = new TimeSpan(15, 0, 0)
},
new()
{
AppointmentId = 3,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 02),
StartHour = new TimeSpan(08, 0, 0)
},
new()
{
AppointmentId = 4,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 01),
StartHour = new TimeSpan(09, 0, 0)
},
new()
{
AppointmentId = 5,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 01),
StartHour = new TimeSpan(13, 0, 0)
}
}
};
var claims = new Claim[]
Expand Down Expand Up @@ -97,13 +155,49 @@ public async Task ExecuteAsync_WhenAppointmentsCannotBeCancelled_ShouldReturnsRe
var expectedMessage = new AppointmentThatHasAlreadyPassedEmployeeError(pastAppointments).Message;
var request = new CancelAppointmentsRequest
{
Reason = "Reason",
Appointments = new List<CancelAppointmentsRequest.Appointment>
{
new () { AppointmentId = 1, AppointmentDate = new DateTime(2022, 08, 02), StartHour = new TimeSpan(14, 0, 0) },
new () { AppointmentId = 2, AppointmentDate = new DateTime(2022, 08, 02), StartHour = new TimeSpan(15, 0, 0) },
new () { AppointmentId = 3, AppointmentDate = new DateTime(2022, 08, 02), StartHour = new TimeSpan(08, 0, 0) },
new () { AppointmentId = 4, AppointmentDate = new DateTime(2022, 08, 01), StartHour = new TimeSpan(09, 0, 0) },
new () { AppointmentId = 5, AppointmentDate = new DateTime(2022, 08, 01), StartHour = new TimeSpan(13, 0, 0) }
new()
{
AppointmentId = 1,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 02),
StartHour = new TimeSpan(14, 0, 0)
},
new()
{
AppointmentId = 2,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 02),
StartHour = new TimeSpan(15, 0, 0)
},
new()
{
AppointmentId = 3,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 02),
StartHour = new TimeSpan(08, 0, 0)
},
new()
{
AppointmentId = 4,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 01),
StartHour = new TimeSpan(09, 0, 0)
},
new()
{
AppointmentId = 5,
PatientName = "Bob",
PatientCellPhone = "3053581032",
AppointmentDate = new DateTime(2022, 08, 01),
StartHour = new TimeSpan(13, 0, 0)
}
}
};
var claims = new Claim[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ public void TestInitialize()
public async Task ExecuteAsync_WhenAppointmentDateIsPublicHoliday_ShouldReturnsAnErrorMessage()
{
// Arrange
var request = new AvailableTimeRangeRequest { AppointmentDate = new DateTime(2023, 01, 01) };
var request = new AvailableTimeRangeRequest
{
OfficeId = 1,
DentistId = 1,
DentalServiceId = 1,
AppointmentDate = new DateTime(2023, 01, 01)
};
Mock.Arrange(() => _queries.IsPublicHolidayAsync(Arg.AnyInt, Arg.AnyInt, Arg.AnyInt))
.ReturnsAsync(true);

Expand All @@ -38,7 +44,13 @@ public async Task ExecuteAsync_WhenDentistIsNotAvailableOnGivenDay_ShouldReturns
// Arrange
var weekDayName = WeekdayCollection.GetName(DayOfWeek.Sunday);
var expectedMessage = new DentistNotAvailableError(weekDayName).Message;
var request = new AvailableTimeRangeRequest { AppointmentDate = new DateTime(2023, 01, 01) };
var request = new AvailableTimeRangeRequest
{
OfficeId = 1,
DentistId = 1,
DentalServiceId = 1,
AppointmentDate = new DateTime(2023, 01, 01)
};
Mock.Arrange(() => _queries.GetEmployeeScheduleAsync(Arg.AnyInt, Arg.AnyInt))
.DoNothing();

Expand All @@ -57,7 +69,13 @@ public async Task ExecuteAsync_WhenEmployeeScheduleIsInactive_ShouldReturnsAnErr
// Arrange
var weekDayName = WeekdayCollection.GetName(DayOfWeek.Sunday);
var expectedMessage = new DentistNotAvailableError(weekDayName).Message;
var request = new AvailableTimeRangeRequest { AppointmentDate = new DateTime(2023, 01, 01) };
var request = new AvailableTimeRangeRequest
{
OfficeId = 1,
DentistId = 1,
DentalServiceId = 1,
AppointmentDate = new DateTime(2023, 01, 01)
};
Mock.Arrange(() => _queries.GetEmployeeScheduleAsync(Arg.AnyInt, Arg.AnyInt))
.ReturnsAsync(new EmployeeScheduleResponse { IsEmployeeScheculeDeleted = true });

Expand All @@ -76,7 +94,13 @@ public async Task ExecuteAsync_WhenOfficeScheduleIsInactive_ShouldReturnsAnError
// Arrange
var weekDayName = WeekdayCollection.GetName(DayOfWeek.Sunday);
var expectedMessage = new OfficeClosedForSpecificDayError(weekDayName).Message;
var request = new AvailableTimeRangeRequest { AppointmentDate = new DateTime(2023, 01, 01) };
var request = new AvailableTimeRangeRequest
{
OfficeId = 1,
DentistId = 1,
DentalServiceId = 1,
AppointmentDate = new DateTime(2023, 01, 01)
};
Mock.Arrange(() => _queries.GetEmployeeScheduleAsync(Arg.AnyInt, Arg.AnyInt))
.ReturnsAsync(new EmployeeScheduleResponse { IsOfficeScheduleDeleted = true });

Expand All @@ -95,7 +119,13 @@ public async Task ExecuteAsync_WhenOfficeIsInactive_ShouldReturnsAnErrorMessage(
// Arrange
var weekDayName = WeekdayCollection.GetName(DayOfWeek.Sunday);
var expectedMessage = new OfficeClosedForSpecificDayError(weekDayName).Message;
var request = new AvailableTimeRangeRequest { AppointmentDate = new DateTime(2023, 01, 01) };
var request = new AvailableTimeRangeRequest
{
OfficeId = 1,
DentistId = 1,
DentalServiceId = 1,
AppointmentDate = new DateTime(2023, 01, 01)
};
Mock.Arrange(() => _queries.GetEmployeeScheduleAsync(Arg.AnyInt, Arg.AnyInt))
.ReturnsAsync(new EmployeeScheduleResponse { IsOfficeDeleted = true });

Expand All @@ -112,7 +142,13 @@ public async Task ExecuteAsync_WhenOfficeIsInactive_ShouldReturnsAnErrorMessage(
public async Task ExecuteAsync_WhenEmployeeDoesNotHaveMorningOrAfternoonSchedule_ShouldReturnsAnErrorMessage()
{
// Arrange
var request = new AvailableTimeRangeRequest();
var request = new AvailableTimeRangeRequest
{
OfficeId = 1,
DentistId = 1,
DentalServiceId = 1,
AppointmentDate = new DateTime(2023, 01, 01)
};
Mock.Arrange(() => _queries.GetEmployeeScheduleAsync(Arg.AnyInt, Arg.AnyInt))
.ReturnsAsync(new EmployeeScheduleResponse());

Expand All @@ -129,7 +165,13 @@ public async Task ExecuteAsync_WhenEmployeeDoesNotHaveMorningOrAfternoonSchedule
public async Task ExecuteAsync_WhenDentalServiceIdIsInvalid_ShouldReturnsAnErrorMessage()
{
// Arrange
var request = new AvailableTimeRangeRequest();
var request = new AvailableTimeRangeRequest
{
OfficeId = 1,
DentistId = 1,
DentalServiceId = 1,
AppointmentDate = new DateTime(2023, 01, 01)
};
Mock.Arrange(() => _queries.GetEmployeeScheduleAsync(Arg.AnyInt, Arg.AnyInt))
.ReturnsAsync(new EmployeeScheduleResponse
{
Expand All @@ -152,7 +194,13 @@ public async Task ExecuteAsync_WhenDentalServiceIdIsInvalid_ShouldReturnsAnError
public async Task ExecuteAsync_WhenEmployeeHasMorningAndAfternoonSchedule_ShouldReturnsAvailableHours()
{
// Arrange
var request = new AvailableTimeRangeRequest() { AppointmentDate = new DateTime(2022, 05, 10) };
var request = new AvailableTimeRangeRequest
{
OfficeId = 1,
DentistId = 1,
DentalServiceId = 1,
AppointmentDate = new DateTime(2022, 05, 10)
};
var expectedList = new List<AvailableTimeRangeResponse>
{
new() { StartHour = "09:00", EndHour = "09:40" },
Expand Down Expand Up @@ -197,7 +245,13 @@ public async Task ExecuteAsync_WhenEmployeeHasMorningAndAfternoonSchedule_Should
public async Task ExecuteAsync_WhenEmployeeHasMorningSchedule_ShouldReturnsAvailableHours()
{
// Arrange
var request = new AvailableTimeRangeRequest() { AppointmentDate = new DateTime(2022, 05, 10) };
var request = new AvailableTimeRangeRequest
{
OfficeId = 1,
DentistId = 1,
DentalServiceId = 1,
AppointmentDate = new DateTime(2022, 05, 10)
};
var expectedList = new List<AvailableTimeRangeResponse>
{
new() { StartHour = "09:00", EndHour = "09:40" },
Expand Down Expand Up @@ -235,7 +289,13 @@ public async Task ExecuteAsync_WhenEmployeeHasMorningSchedule_ShouldReturnsAvail
public async Task ExecuteAsync_WhenEmployeeHasAfternoonSchedule_ShouldReturnsAvailableHours()
{
// Arrange
var request = new AvailableTimeRangeRequest() { AppointmentDate = new DateTime(2022, 05, 10) };
var request = new AvailableTimeRangeRequest
{
OfficeId = 1,
DentistId = 1,
DentalServiceId = 1,
AppointmentDate = new DateTime(2022, 05, 10)
};
var expectedList = new List<AvailableTimeRangeResponse>
{
new() { StartHour = "13:00", EndHour = "13:40" },
Expand Down Expand Up @@ -271,7 +331,13 @@ public async Task ExecuteAsync_WhenEmployeeHasAfternoonSchedule_ShouldReturnsAva
public async Task ExecuteAsync_WhenSchedulesAreNotAvailable_ShouldReturnsResultWithoutAvailableHours()
{
// Arrange
var request = new AvailableTimeRangeRequest() { AppointmentDate = new DateTime(2022, 05, 10) };
var request = new AvailableTimeRangeRequest
{
OfficeId = 1,
DentistId = 1,
DentalServiceId = 1,
AppointmentDate = new DateTime(2022, 05, 10)
};
Mock.Arrange(() => _dateTimeService.Now).Returns(new DateTime(2022, 05, 01, 8, 30, 0));
Mock.Arrange(() => _queries.GetEmployeeScheduleAsync(Arg.AnyInt, Arg.AnyInt))
.ReturnsAsync(new EmployeeScheduleResponse
Expand Down Expand Up @@ -300,5 +366,3 @@ public async Task ExecuteAsync_WhenSchedulesAreNotAvailable_ShouldReturnsResultW
result.Message.Should().Be(Messages.NoSchedulesAvailable);
}
}


0 comments on commit 75a2946

Please sign in to comment.