public void AddStreamRecorderAsync_Throws_AudioPlatformException_On_Http_Failure() { // Case 1 var wowzaHttpClient = new WowzaHttpClient(new HttpClient(new FakeHttpMessageHandler()) { BaseAddress = new Uri($"http://{nameof(Exception)}.com/") }); var client = wowzaHttpClient; var exception = Assert.ThrowsAsync <Exception> ( () => client.AddStreamRecorderAsync ( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>() ) ); exception.Message.Should().Be("Exception thrown"); // Case 2 wowzaHttpClient = new WowzaHttpClient(new HttpClient(new FakeHttpMessageHandler()) { BaseAddress = new Uri($"http://{HttpStatusCode.BadRequest}.com/") }); exception = Assert.ThrowsAsync <AudioPlatformException> ( () => wowzaHttpClient.AddStreamRecorderAsync ( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>() ) ); exception.Message.Should().Be("Bad request"); }
public void AddStreamRecorderAsync_Success() { // Case 1 var wowzaHttpClient = new WowzaHttpClient(new HttpClient(new FakeHttpMessageHandler()) { BaseAddress = new Uri($"http://{HttpStatusCode.OK}.com/") }); var result = wowzaHttpClient.AddStreamRecorderAsync ( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>() ); result.IsCompleted.Should().BeTrue(); result.IsFaulted.Should().BeFalse(); }