Skip to content

Commit

Permalink
test: suggestedDates Description
Browse files Browse the repository at this point in the history
  • Loading branch information
BGruenberg committed Aug 22, 2024
1 parent ac6d601 commit 0af9d73
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ protected Appointment CreateTestAppointment(Guid customerId, Guid adminId, strin
return appointment;
}

protected async Task<Appointment> CreateTestAppointmentInDatabase(HttpClient client, Guid customerId, string password = null)
protected async Task<Appointment> CreateTestAppointmentInDatabase(
HttpClient client,
Guid customerId,
string password = null,
Appointment appointment = null
)
{
var appointment = CreateTestAppointment(customerId, Guid.Empty, password);
appointment ??= CreateTestAppointment(customerId, Guid.Empty, password);

// Act
var content = new StringContent(JsonConvert.SerializeObject(appointment), Encoding.UTF8, HttpConstants.TerminfinderMediaTypeJsonV1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class SuggestedDateControllerIntegrationTests : BaseIntegrationTests
private Guid _customerId = new("E1E81104-3944-4588-A48E-B64BDE473E1A");

[TestInitialize]
public void Inilialize()
public void Initialize()
{
var config = GetConfigurationBuilder();
var builder = new WebHostBuilder().UseStartup<Startup>().UseConfiguration(config);
Expand Down Expand Up @@ -97,4 +97,23 @@ public async Task DeleteSuggestedDates_AppointmentIsPasswordProtectedNoPasswordS
Assert.IsNotNull(result);
Assert.AreEqual(HttpStatusCode.Unauthorized, result.StatusCode);
}

[TestMethod]
public async Task AddSuggestedDateDescription_GetSuggestedDate_ValueMatches()
{
// arrange
const string description = "Im the test description!";
HttpClient client = _testServer.CreateClient();

var appointment = CreateTestAppointment(_customerId, It.IsAny<Guid>());
appointment.SuggestedDates.First().Description = description;

// act
var result = await CreateTestAppointmentInDatabase(client, _customerId, null, appointment);

// assert
var resultDescription = result.SuggestedDates.First().Description;
Assert.IsNotNull(resultDescription);
Assert.AreEqual(resultDescription, description);
}
}

0 comments on commit 0af9d73

Please sign in to comment.