Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase Rooms .Net SDK code coverage #37866

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,20 @@ public void CreateRoom_WithTimeRangeExceedMax_Fail()
Assert.AreEqual(400, ex?.Status);
}

[Test]
public void CreateRoom_WithPastValidUntil_Fail()
{
// Arrange;
var roomsClient = CreateInstrumentedRoomsClient(RoomsClientOptions.ServiceVersion.V2023_06_14);
var validFrom = DateTime.UtcNow.AddDays(-10);
var validUntil = validFrom.AddDays(-20);

// Act and Assert
RequestFailedException? ex = Assert.ThrowsAsync<RequestFailedException>(async () => await roomsClient.CreateRoomAsync(validFrom: validFrom, validUntil: validUntil));
Assert.NotNull(ex);
Assert.AreEqual(400, ex?.Status);
}

[Test]
public void CreateRoom_WithInvalidParticipantMri_Fail()
{
Expand Down Expand Up @@ -272,6 +286,22 @@ public async Task UpdateRoom_WithTimeRangeExceedMax_Fail()
Assert.AreEqual(400, ex?.Status);
}

[Test]
public async Task UpdateRoom_WithPastValidUntil_Fail()
{
// Arrange
var validFrom = DateTime.UtcNow;
var validUntil = validFrom.AddDays(10);
var roomsClient = CreateInstrumentedRoomsClient(RoomsClientOptions.ServiceVersion.V2023_06_14);
var createRoomResponse = await roomsClient.CreateRoomAsync(validFrom: validFrom, validUntil: validUntil);

// Act and Assert
validUntil = validFrom.AddDays(-20);
RequestFailedException? ex = Assert.ThrowsAsync<RequestFailedException>(async () => await roomsClient.UpdateRoomAsync(createRoomResponse.Value.Id, validFrom: validFrom, validUntil: validUntil));
Assert.NotNull(ex);
Assert.AreEqual(400, ex?.Status);
}

[Test]
public void UpdateRoom_WithInvalidFormatRoomId_Fail()
{
Expand Down Expand Up @@ -319,23 +349,25 @@ public async Task AddOrUpdateParticipants_IncorrectlyFormattedMri_Fail()
}

[Test]
public async Task GetRoomsLiveTest_FirstRoomIsNotNull_Succeed()
public async Task GetRoomsLiveTest_FirstTwoPagesOfRoomIsNotNull_Succeed()
{
// Arrange
RoomsClient roomsClient = CreateInstrumentedRoomsClient(RoomsClientOptions.ServiceVersion.V2023_06_14);
// First create a room to ensure that the list rooms will not be empty.
CommunicationRoom createdRoom = await roomsClient.CreateRoomAsync();
CommunicationRoom? firstActiveRoom = null;
int roomCounter = 0;
try
{
AsyncPageable<CommunicationRoom> allActiveRooms = roomsClient.GetRoomsAsync();
await foreach (CommunicationRoom room in allActiveRooms)
{
firstActiveRoom = room;
break;
if (roomCounter > 60)
{
break;
}
ValidateRoom(room);
roomCounter++;
}

ValidateRoom(firstActiveRoom);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -626,6 +658,19 @@ public async Task DeleteRoom_Success()
Assert.AreEqual(404, ex?.Status);
}

[Test]
public void DeleteRoomDoesNotExist_Fail()
{
// Arrange
var roomsClient = CreateInstrumentedRoomsClient(RoomsClientOptions.ServiceVersion.V2023_06_14);
var ivnalidRoomId = "99437728598278806";

// Act and Assert:
RequestFailedException? ex = Assert.ThrowsAsync<RequestFailedException>(async () => await roomsClient.DeleteRoomAsync(ivnalidRoomId));
Assert.NotNull(ex);
Assert.AreEqual(404, ex?.Status);
}

private void ValidateRoom(CommunicationRoom? room)
{
Assert.NotNull(room);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading