Skip to content

Commit

Permalink
Increase Rooms .Net SDK code coverage (#37866)
Browse files Browse the repository at this point in the history
* Increase Rooms .Net SDK code coverage

* List Room get first two pages

---------

Co-authored-by: Minnie Liu <peiliu@microsoft.com>
  • Loading branch information
minnieliu and Minnie Liu authored Jul 27, 2023
1 parent 62da64b commit a841b1b
Show file tree
Hide file tree
Showing 11 changed files with 1,801 additions and 444 deletions.
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

0 comments on commit a841b1b

Please sign in to comment.