/** * Stops the OpenTok archive if it is being recorded. * <p> * Archives automatically stop recording after 90 minutes or when all clients have disconnected from the * session being archived. */ public void Stop() { if (opentok != null) { Archive archive = opentok.StopArchive(Id.ToString()); Status = archive.Status; } }
public void StopArchiveTest() { string archiveId = "30b3ebf1-ba36-4f5b-8def-6f70d9986fe9"; string returnString = "{\n" + " \"createdAt\" : 1395183243556,\n" + " \"duration\" : 0,\n" + " \"id\" : \"30b3ebf1-ba36-4f5b-8def-6f70d9986fe9\",\n" + " \"name\" : \"\",\n" + " \"partnerId\" : 123456,\n" + " \"reason\" : \"\",\n" + " \"sessionId\" : \"SESSIONID\",\n" + " \"size\" : 0,\n" + " \"status\" : \"started\",\n" + " \"url\" : null\n" + " }"; var mockClient = new Mock<HttpClient>(); mockClient.Setup(httpClient => httpClient.Post(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>(), It.IsAny<Dictionary<string, object>>())).Returns(returnString); OpenTok opentok = new OpenTok(apiKey, apiSecret); opentok.Client = mockClient.Object; Archive archive = opentok.StopArchive(archiveId); Assert.NotNull(archive); Assert.Equal("SESSIONID", archive.SessionId); Assert.Equal(archiveId, archive.Id.ToString()); mockClient.Verify(httpClient => httpClient.Post(It.Is<string>( url => url.Equals("v2/partner/" + apiKey + "/archive/" + archiveId +"/stop")), It.IsAny<Dictionary<string, string>>(), It.IsAny<Dictionary<string, object>>()), Times.Once()); }