diff --git a/examples/OpenAIExamples/WebRTCOpenAI/Program.cs b/examples/OpenAIExamples/WebRTCOpenAI/Program.cs index 1014be426..ffe8f398b 100755 --- a/examples/OpenAIExamples/WebRTCOpenAI/Program.cs +++ b/examples/OpenAIExamples/WebRTCOpenAI/Program.cs @@ -218,7 +218,7 @@ private static async Task CreatePeerConnection(SemaphoreSlim WindowsAudioEndPoint windowsAudioEP = new WindowsAudioEndPoint(new AudioEncoder(includeOpus: true), -1, -1, false, false); windowsAudioEP.RestrictFormats(x => x.FormatName == "OPUS"); windowsAudioEP.OnAudioSinkError += err => logger.LogWarning($"Audio sink error. {err}."); - windowsAudioEP.OnAudioSourceEncodedSample += peerConnection.SendAudio; + windowsAudioEP.OnAudioSourceEncodedSample += peerConnection.SendAudio; MediaStreamTrack audioTrack = new MediaStreamTrack(windowsAudioEP.GetAudioSourceFormats(), MediaStreamStatusEnum.SendRecv); peerConnection.addTrack(audioTrack); diff --git a/src/app/Media/Sources/AudioSignalGenerator.cs b/src/app/Media/Sources/AudioSignalGenerator.cs index a74614c14..48be4b417 100644 --- a/src/app/Media/Sources/AudioSignalGenerator.cs +++ b/src/app/Media/Sources/AudioSignalGenerator.cs @@ -156,7 +156,6 @@ public int Read(float[] buffer, int offset, int count) break; - case SignalGeneratorType.Square: // Square Generator diff --git a/src/app/Media/VoIPMediaSession.cs b/src/app/Media/VoIPMediaSession.cs index 702ad18de..ed1bc95b5 100755 --- a/src/app/Media/VoIPMediaSession.cs +++ b/src/app/Media/VoIPMediaSession.cs @@ -187,7 +187,7 @@ private void AudioFormatsNegotiated(List audoFormats) Media.AudioSource?.SetAudioSourceFormat(audioFormat); _audioExtrasSource.SetAudioSourceFormat(audioFormat); - if (AudioStream != null && AudioStream.LocalTrack.NoDtmfSupport == false) + if (AudioStream != null && !AudioStream.LocalTrack.NoDtmfSupport) { logger.LogDebug("Audio track negotiated DTMF payload ID {AudioStreamNegotiatedRtpEventPayloadID}.", AudioStream.NegotiatedRtpEventPayloadID); } diff --git a/src/app/SIPUserAgents/SIPClientUserAgent.cs b/src/app/SIPUserAgents/SIPClientUserAgent.cs index 15c303a72..83296854c 100644 --- a/src/app/SIPUserAgents/SIPClientUserAgent.cs +++ b/src/app/SIPUserAgents/SIPClientUserAgent.cs @@ -561,7 +561,7 @@ private SIPRequest GetInviteRequest(SIPCallDescriptor sipCallDescriptor, string inviteHeader.UserAgent = SIPConstants.SipUserAgentVersionString; inviteHeader.Routes = routeSet; inviteHeader.Supported = SIPExtensionHeaders.REPLACES + ", " + SIPExtensionHeaders.NO_REFER_SUB - + ((PrackSupported == true) ? ", " + SIPExtensionHeaders.PRACK : ""); + + (PrackSupported ? ", " + SIPExtensionHeaders.PRACK : ""); inviteRequest.Header = inviteHeader; diff --git a/src/app/SIPUserAgents/SIPServerUserAgent.cs b/src/app/SIPUserAgents/SIPServerUserAgent.cs index 166e11e21..c27a54b38 100644 --- a/src/app/SIPUserAgents/SIPServerUserAgent.cs +++ b/src/app/SIPUserAgents/SIPServerUserAgent.cs @@ -452,7 +452,7 @@ public void Hangup(bool clientHungup) } // Only need to send a BYE request if the client didn't already do so. - if (clientHungup == false) + if (!clientHungup) { try { diff --git a/src/app/SIPUserAgents/SIPUserAgent.cs b/src/app/SIPUserAgents/SIPUserAgent.cs index d78f71adf..3823d9d93 100755 --- a/src/app/SIPUserAgents/SIPUserAgent.cs +++ b/src/app/SIPUserAgents/SIPUserAgent.cs @@ -561,7 +561,7 @@ public void Cancel() { if (m_uac != null) { - if (m_uac.IsUACAnswered == false) + if (!m_uac.IsUACAnswered) { m_uac.Cancel(); } @@ -1778,10 +1778,10 @@ private void CallEnded(string callId) m_semaphoreSlim.Wait(); CallEndedSyncronized(callId); } - catch (ObjectDisposedException) - { - //Swallow it - } + catch (ObjectDisposedException) + { + //Swallow it + } finally { TryReleaseSemaphore(); @@ -1974,17 +1974,17 @@ public void Dispose() TryReleaseSemaphore(); m_semaphoreSlim.Dispose(); } - - private void TryReleaseSemaphore() - { - try - { - m_semaphoreSlim.Release(); - } - catch (ObjectDisposedException) - { - //Swallow it - } - } + + private void TryReleaseSemaphore() + { + try + { + m_semaphoreSlim.Release(); + } + catch (ObjectDisposedException) + { + //Swallow it + } + } } } diff --git a/src/core/SIP/Channels/SIPClientWebSocketChannel.cs b/src/core/SIP/Channels/SIPClientWebSocketChannel.cs index 423842a24..c0be30578 100644 --- a/src/core/SIP/Channels/SIPClientWebSocketChannel.cs +++ b/src/core/SIP/Channels/SIPClientWebSocketChannel.cs @@ -371,7 +371,7 @@ private void MonitorReceiveTasks() var receiveTasks = m_egressConnections.Select(x => x.Value.ReceiveTask).ToArray(); int completedTaskIndex = Task.WaitAny(receiveTasks); Task receiveTask = receiveTasks[completedTaskIndex]; - var conn = m_egressConnections.Where(x => x.Value.ReceiveTask.Id == receiveTask.Id).Single().Value; + var conn = m_egressConnections.Single(x => x.Value.ReceiveTask.Id == receiveTask.Id).Value; if (receiveTask.IsCompleted) { diff --git a/src/core/SIP/Channels/SIPTCPChannel.cs b/src/core/SIP/Channels/SIPTCPChannel.cs index e344d09e2..59631dd9f 100644 --- a/src/core/SIP/Channels/SIPTCPChannel.cs +++ b/src/core/SIP/Channels/SIPTCPChannel.cs @@ -690,7 +690,7 @@ public override bool IsProtocolSupported(SIPProtocolsEnum protocol) /// public override void Close() { - if (!Closed == true) + if (!Closed) { logger.LogDebug("Closing SIP {ProtDescr} Channel {ListeningEndPoint}.", ProtDescr, ListeningEndPoint); diff --git a/src/core/SIP/SIPConstants.cs b/src/core/SIP/SIPConstants.cs index 922db9c3a..516dd55ce 100644 --- a/src/core/SIP/SIPConstants.cs +++ b/src/core/SIP/SIPConstants.cs @@ -232,14 +232,7 @@ public static bool IsAllowedProtocol(string protocol) /// True if the protocol is connectionless. public static bool IsConnectionless(SIPProtocolsEnum protocol) { - if (protocol == SIPProtocolsEnum.udp) - { - return true; - } - else - { - return false; - } + return protocol == SIPProtocolsEnum.udp; } } diff --git a/src/core/SIP/SIPHeader.cs b/src/core/SIP/SIPHeader.cs index 2e937bf0e..d62911059 100644 --- a/src/core/SIP/SIPHeader.cs +++ b/src/core/SIP/SIPHeader.cs @@ -1153,7 +1153,7 @@ public void RemoveBottomRoute() if (m_sipRoutes.Count > 0) { m_sipRoutes.RemoveAt(m_sipRoutes.Count - 1); - }; + } } public SIPRouteSet Reversed() diff --git a/src/core/SIPEvents/SIPEventPackages.cs b/src/core/SIPEvents/SIPEventPackages.cs index 9159fe5dd..a4fdde3d9 100644 --- a/src/core/SIPEvents/SIPEventPackages.cs +++ b/src/core/SIPEvents/SIPEventPackages.cs @@ -104,7 +104,7 @@ public static SIPEventPackagesEnum Parse(string value) public static string GetEventHeader(SIPEventPackagesEnum eventPackage) { - switch(eventPackage) + switch (eventPackage) { case SIPEventPackagesEnum.Dialog: return DIALOG_EVENT_VALUE; diff --git a/src/core/SIPTransactions/SIPTransaction.cs b/src/core/SIPTransactions/SIPTransaction.cs index 8ef0dfc7e..29ad70c52 100644 --- a/src/core/SIPTransactions/SIPTransaction.cs +++ b/src/core/SIPTransactions/SIPTransaction.cs @@ -388,7 +388,7 @@ protected virtual Task SendProvisionalResponse(SIPResponse sipRespo { UpdateTransactionState(SIPTransactionStatesEnum.Proceeding); - if (PrackSupported == true) + if (PrackSupported) { if (RSeq == 0) { diff --git a/src/core/SIPTransactions/UACInviteTransaction.cs b/src/core/SIPTransactions/UACInviteTransaction.cs index 7cbc2e480..650d6544d 100644 --- a/src/core/SIPTransactions/UACInviteTransaction.cs +++ b/src/core/SIPTransactions/UACInviteTransaction.cs @@ -147,7 +147,7 @@ private async Task UACInviteTransaction_TransactionFinalResponseRec // BranchId for 2xx responses needs to be a new one, non-2xx final responses use same one as original request. if (sipResponse.StatusCode >= 200 && sipResponse.StatusCode < 299) { - if (_sendOkAckManually == false) + if (!_sendOkAckManually) { AckRequest = GetAcknowledgeRequest(sipResponse, SIPMethodsEnum.ACK, sipResponse.Header.CSeq, null, null); await SendRequestAsync(AckRequest).ConfigureAwait(false); diff --git a/src/core/SIPTransactions/UASInviteTransaction.cs b/src/core/SIPTransactions/UASInviteTransaction.cs index a994b3a1a..71ee79b41 100644 --- a/src/core/SIPTransactions/UASInviteTransaction.cs +++ b/src/core/SIPTransactions/UASInviteTransaction.cs @@ -156,7 +156,7 @@ public SIPResponse GetOkResponse(string contentType, string messageBody) okResponse.Header.MaxForwards = Int32.MinValue; okResponse.Header.RecordRoutes = requestHeader.RecordRoutes; okResponse.Header.Supported = SIPExtensionHeaders.REPLACES + ", " + SIPExtensionHeaders.NO_REFER_SUB - + ((PrackSupported == true) ? ", " + SIPExtensionHeaders.PRACK : ""); + + (PrackSupported ? ", " + SIPExtensionHeaders.PRACK : ""); okResponse.Body = messageBody; okResponse.Header.ContentType = contentType; diff --git a/src/net/ICE/RtpIceChannel.cs b/src/net/ICE/RtpIceChannel.cs index d53cd7f3a..55b9c0287 100755 --- a/src/net/ICE/RtpIceChannel.cs +++ b/src/net/ICE/RtpIceChannel.cs @@ -908,7 +908,7 @@ public void AddRemoteCandidate(RTCIceCandidate candidate) { OnIceCandidateError?.Invoke(candidate, $"Remote ICE candidate had an invalid port {candidate.port}."); } - else if(IPAddress.TryParse(candidate.address, out var addrIPv6) && + else if (IPAddress.TryParse(candidate.address, out var addrIPv6) && addrIPv6.AddressFamily == AddressFamily.InterNetworkV6 && !Socket.OSSupportsIPv6 && NetServices.HasActiveIPv6Address()) @@ -1506,12 +1506,12 @@ private void AddChecklistEntry(ChecklistEntry entry) lock (_checklistLock) { - var existingEntry = _checklist.Where(x => + var existingEntry = _checklist.SingleOrDefault(x => x.LocalCandidate.type == entry.LocalCandidate.type && x.RemoteCandidate.DestinationEndPoint != null && x.RemoteCandidate.DestinationEndPoint.Address.Equals(entryRemoteEP.Address) && x.RemoteCandidate.DestinationEndPoint.Port == entryRemoteEP.Port - && x.RemoteCandidate.protocol == entry.RemoteCandidate.protocol).SingleOrDefault(); + && x.RemoteCandidate.protocol == entry.RemoteCandidate.protocol); if (existingEntry != null) { @@ -2270,8 +2270,7 @@ private IceServer GetIceServerForTransactionID(byte[] transactionID) string txID = Encoding.ASCII.GetString(transactionID); var entry = _iceServerConnections - .Where(x => x.Value.IsTransactionIDMatch(txID)) - .SingleOrDefault(); + .SingleOrDefault(x => x.Value.IsTransactionIDMatch(txID)); if (!entry.Equals(default(KeyValuePair))) { @@ -2669,7 +2668,7 @@ private async Task ResolveMdnsName(RTCIceCandidate candidate) { if (MdnsResolve != null) { - logger.LogWarning("RTP ICE channel has both "+ nameof(MdnsGetAddresses) + " and " + nameof(MdnsGetAddresses) + " set. Only " + nameof(MdnsGetAddresses) + " will be used."); + logger.LogWarning("RTP ICE channel has both " + nameof(MdnsGetAddresses) + " and " + nameof(MdnsGetAddresses) + " set. Only " + nameof(MdnsGetAddresses) + " will be used."); } return await MdnsGetAddresses(candidate.address).ConfigureAwait(false); } diff --git a/src/net/WebRTC/RTCPeerConnection.cs b/src/net/WebRTC/RTCPeerConnection.cs index 9aea1c8b6..061838839 100755 --- a/src/net/WebRTC/RTCPeerConnection.cs +++ b/src/net/WebRTC/RTCPeerConnection.cs @@ -1301,7 +1301,7 @@ void AddIceCandidates(SDPMediaAnnouncement announcement) announcement.IceRole = IceRole; announcement.DtlsFingerprint = dtlsFingerprint; - if (iceCandidatesAdded == false && !excludeIceCandidates) + if (!iceCandidatesAdded && !excludeIceCandidates) { AddIceCandidates(announcement); iceCandidatesAdded = true; @@ -1349,7 +1349,7 @@ void AddIceCandidates(SDPMediaAnnouncement announcement) dataChannelAnnouncement.IceRole = IceRole; dataChannelAnnouncement.DtlsFingerprint = dtlsFingerprint; - if (iceCandidatesAdded == false && !excludeIceCandidates) + if (!iceCandidatesAdded && !excludeIceCandidates) { AddIceCandidates(dataChannelAnnouncement); iceCandidatesAdded = true; diff --git a/src/sys/StorageTypes.cs b/src/sys/StorageTypes.cs index 4843bbd70..cef56a517 100644 --- a/src/sys/StorageTypes.cs +++ b/src/sys/StorageTypes.cs @@ -37,7 +37,7 @@ public enum StorageTypes public class StorageTypesConverter { - private static ILogger logger = Log.Logger; + private static readonly ILogger logger = Log.Logger; public static StorageTypes GetStorageType(string storageType) { diff --git a/src/sys/TypeExtensions.cs b/src/sys/TypeExtensions.cs index b78c422e7..b069f28f7 100644 --- a/src/sys/TypeExtensions.cs +++ b/src/sys/TypeExtensions.cs @@ -65,12 +65,7 @@ public static bool IsNullOrBlank(this string s) public static bool NotNullOrBlank(this string s) { - if (s == null || s.Trim(WhiteSpaceChars).Length == 0) - { - return false; - } - - return true; + return !s.IsNullOrBlank(); } public static long GetEpoch(this DateTime dateTime) diff --git a/test/integration/core/SIPTransportIntegrationTest.cs b/test/integration/core/SIPTransportIntegrationTest.cs index 2f7ed8446..84cdd81a3 100644 --- a/test/integration/core/SIPTransportIntegrationTest.cs +++ b/test/integration/core/SIPTransportIntegrationTest.cs @@ -85,7 +85,7 @@ await RunClient( logger.LogWarning("Tasks timed out"); } - if (testComplete.Task.IsCompleted == false) + if (!testComplete.Task.IsCompleted) { // The client did not set the completed signal. This means the delay task must have completed and hence the test failed. testComplete.SetResult(false); @@ -132,7 +132,7 @@ await RunClient( logger.LogWarning("Tasks timed out"); } - if (testComplete.Task.IsCompleted == false) + if (!testComplete.Task.IsCompleted) { // The client did not set the completed signal. This means the delay task must have completed and hence the test failed. testComplete.SetResult(false); @@ -188,7 +188,7 @@ await RunClient( logger.LogWarning("Tasks timed out"); } - if (testComplete.Task.IsCompleted == false) + if (!testComplete.Task.IsCompleted) { // The client did not set the completed signal. This means the delay task must have completed and hence the test failed. testComplete.SetResult(false); @@ -237,7 +237,7 @@ await RunClient( logger.LogWarning("Tasks timed out"); } - if (testComplete.Task.IsCompleted == false) + if (!testComplete.Task.IsCompleted) { // The client did not set the completed signal. This means the delay task must have completed and hence the test failed. testComplete.SetResult(false); @@ -291,7 +291,7 @@ public void IPv4TcpLoopbackConsecutiveSendReceiveTest() logger.LogWarning("Tasks timed out"); } - if (testComplete.Task.IsCompleted == false) + if (!testComplete.Task.IsCompleted) { // The client did not set the completed signal. This means the delay task must have completed and hence the test failed. testComplete.SetResult(false); @@ -364,7 +364,7 @@ await RunClient( logger.LogWarning("Tasks timed out"); } - if (testComplete.Task.IsCompleted == false) + if (!testComplete.Task.IsCompleted) { // The client did not set the completed signal. This means the delay task must have completed and hence the test failed. testComplete.SetResult(false); @@ -428,7 +428,7 @@ await RunClient( logger.LogWarning("Tasks timed out"); } - if (testComplete.Task.IsCompleted == false) + if (!testComplete.Task.IsCompleted) { // The client did not set the completed signal. This means the delay task must have completed and hence the test failed. testComplete.SetResult(false); @@ -699,7 +699,7 @@ await RunClient( logger.LogWarning("Tasks timed out"); } - if (testComplete.Task.IsCompleted == false) + if (!testComplete.Task.IsCompleted) { // The client did not set the completed signal. This means the delay task must have completed and hence the test failed. testComplete.SetResult(false); diff --git a/test/unit/net/RTP/RTPSessionUnitTest.cs b/test/unit/net/RTP/RTPSessionUnitTest.cs index 630b6e093..1f0161892 100644 --- a/test/unit/net/RTP/RTPSessionUnitTest.cs +++ b/test/unit/net/RTP/RTPSessionUnitTest.cs @@ -302,8 +302,8 @@ public void AudioVideoOfferNoLocalVideoUnitTest() var answer = localSession.CreateAnswer(null); - Assert.Equal(MediaStreamStatusEnum.SendRecv, answer.Media.Where(x => x.Media == SDPMediaTypesEnum.audio).Single().MediaStreamStatus); - Assert.Equal(MediaStreamStatusEnum.Inactive, answer.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().MediaStreamStatus); + Assert.Equal(MediaStreamStatusEnum.SendRecv, answer.Media.Single(x => x.Media == SDPMediaTypesEnum.audio).MediaStreamStatus); + Assert.Equal(MediaStreamStatusEnum.Inactive, answer.Media.Single(x => x.Media == SDPMediaTypesEnum.video).MediaStreamStatus); localSession.Close("normal"); remoteSession.Close("normal"); @@ -346,8 +346,8 @@ public void AudioVideoOfferNoLocalAudioUnitTest() var answer = localSession.CreateAnswer(null); - Assert.Equal(MediaStreamStatusEnum.Inactive, answer.Media.Where(x => x.Media == SDPMediaTypesEnum.audio).Single().MediaStreamStatus); - Assert.Equal(MediaStreamStatusEnum.SendRecv, answer.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().MediaStreamStatus); + Assert.Equal(MediaStreamStatusEnum.Inactive, answer.Media.Single(x => x.Media == SDPMediaTypesEnum.audio).MediaStreamStatus); + Assert.Equal(MediaStreamStatusEnum.SendRecv, answer.Media.Single(x => x.Media == SDPMediaTypesEnum.video).MediaStreamStatus); localSession.Close("normal"); remoteSession.Close("normal"); diff --git a/test/unit/net/SDP/SDPUnitTests.cs b/test/unit/net/SDP/SDPUnitTests.cs index 57ebb58a0..e644cff83 100755 --- a/test/unit/net/SDP/SDPUnitTests.cs +++ b/test/unit/net/SDP/SDPUnitTests.cs @@ -854,12 +854,12 @@ public void ParseChromeOfferSDPUnitTest() Assert.Equal("BUNDLE 0 1", rndTripSdp.Group); Assert.Single(sdp.Media.First().IceCandidates); Assert.Single(rndTripSdp.Media.First().IceCandidates); - Assert.Contains(sdp.Media.Where(x => x.Media == SDPMediaTypesEnum.audio).Single().SsrcAttributes, x => x.SSRC == 1676157391U); - Assert.Contains(sdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().SsrcAttributes, x => x.SSRC == 3966011320U); - Assert.Contains(sdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().SsrcAttributes, x => x.SSRC == 1316862390U); - Assert.Contains(rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.audio).Single().SsrcAttributes, x => x.SSRC == 1676157391U); - Assert.Contains(rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().SsrcAttributes, x => x.SSRC == 3966011320U); - Assert.Contains(rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().SsrcAttributes, x => x.SSRC == 1316862390U); + Assert.Contains(sdp.Media.Single(x => x.Media == SDPMediaTypesEnum.audio).SsrcAttributes, x => x.SSRC == 1676157391U); + Assert.Contains(sdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).SsrcAttributes, x => x.SSRC == 3966011320U); + Assert.Contains(sdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).SsrcAttributes, x => x.SSRC == 1316862390U); + Assert.Contains(rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.audio).SsrcAttributes, x => x.SSRC == 1676157391U); + Assert.Contains(rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).SsrcAttributes, x => x.SSRC == 3966011320U); + Assert.Contains(rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).SsrcAttributes, x => x.SSRC == 1316862390U); } /// @@ -971,8 +971,8 @@ public void ParseMediaFormatWithHyphenNameUnitTest() SDP rndTripSdp = SDP.ParseSDPDescription(sdp.ToString()); - Assert.Equal(96, rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().MediaFormats.Single().Key); - Assert.Equal("H263-1998", rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().MediaFormats.Single().Value.Name()); + Assert.Equal(96, rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).MediaFormats.Single().Key); + Assert.Equal("H263-1998", rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).MediaFormats.Single().Value.Name()); } /// @@ -1002,8 +1002,8 @@ public void ParseMediaFormatWithFowardSlashUnitTest() SDP rndTripSdp = SDP.ParseSDPDescription(sdp.ToString()); - Assert.Equal(111, rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.audio).Single().MediaFormats.Single().Key); - Assert.Equal("opus", rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.audio).Single().MediaFormats.Single().Value.Name()); + Assert.Equal(111, rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.audio).MediaFormats.Single().Key); + Assert.Equal("opus", rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.audio).MediaFormats.Single().Value.Name()); } /// @@ -1040,10 +1040,10 @@ public void ParseOfferWithFmtpPreceedingRtmapTest() SDP sdp = SDP.ParseSDPDescription(sdpStr); - Assert.Equal(96, sdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().MediaFormats.Single().Key); - Assert.Equal("VP8", sdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().MediaFormats.Single().Value.Name()); - Assert.Equal("VP8/90000", sdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().MediaFormats.Single().Value.Rtpmap); - Assert.Equal("max-fs=12288;max-fr=60", sdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().MediaFormats.Single().Value.Fmtp); + Assert.Equal(96, sdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).MediaFormats.Single().Key); + Assert.Equal("VP8", sdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).MediaFormats.Single().Value.Name()); + Assert.Equal("VP8/90000", sdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).MediaFormats.Single().Value.Rtpmap); + Assert.Equal("max-fs=12288;max-fr=60", sdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).MediaFormats.Single().Value.Fmtp); } /// @@ -1077,8 +1077,8 @@ public void ParseMcpttTest() SDP rndTripSdp = SDP.ParseSDPDescription(sdp.ToString()); - Assert.Equal("MCPTT", rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.application).Single().ApplicationMediaFormats.Single().Key); - Assert.Equal("mc_queueing;mc_priority=4", rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.application).Single().ApplicationMediaFormats.Single().Value.Fmtp); + Assert.Equal("MCPTT", rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.application).ApplicationMediaFormats.Single().Key); + Assert.Equal("mc_queueing;mc_priority=4", rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.application).ApplicationMediaFormats.Single().Value.Fmtp); } /// @@ -1119,8 +1119,8 @@ public void DescriptionAttributeRoundTripTest() SDP rndTripSdp = SDP.ParseSDPDescription(sdp.ToString()); Assert.Equal("A session description", rndTripSdp.SessionDescription); - Assert.Equal("speech", rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.audio).Single().MediaDescription); - Assert.Equal("video title", rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().MediaDescription); + Assert.Equal("speech", rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.audio).MediaDescription); + Assert.Equal("video title", rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).MediaDescription); } /// @@ -1158,7 +1158,7 @@ public void TIASBandwidthAttributeRoundTripTest() SDP rndTripSdp = SDP.ParseSDPDescription(sdp.ToString()); - Assert.Equal(256000U, rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().TIASBandwidth); + Assert.Equal(256000U, rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).TIASBandwidth); } /// @@ -1245,10 +1245,10 @@ public void ParseFireFoxOfferSDPUnitTest() Assert.Equal("BUNDLE 0", rndTripSdp.Group); Assert.Null(sdp.Media.First().IceCandidates); Assert.Null(rndTripSdp.Media.First().IceCandidates); - Assert.Contains(sdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().SsrcAttributes, x => x.SSRC == 3366495178U); - Assert.Contains(sdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().SsrcAttributes, x => x.SSRC == 777490417U); - Assert.Contains(rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().SsrcAttributes, x => x.SSRC == 3366495178U); - Assert.Contains(rndTripSdp.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().SsrcAttributes, x => x.SSRC == 777490417U); + Assert.Contains(sdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).SsrcAttributes, x => x.SSRC == 3366495178U); + Assert.Contains(sdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).SsrcAttributes, x => x.SSRC == 777490417U); + Assert.Contains(rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).SsrcAttributes, x => x.SSRC == 3366495178U); + Assert.Contains(rndTripSdp.Media.Single(x => x.Media == SDPMediaTypesEnum.video).SsrcAttributes, x => x.SSRC == 777490417U); } /// diff --git a/test/unit/net/STUN/STUNUnitTest.cs b/test/unit/net/STUN/STUNUnitTest.cs index 70dd1c533..7feecdead 100755 --- a/test/unit/net/STUN/STUNUnitTest.cs +++ b/test/unit/net/STUN/STUNUnitTest.cs @@ -213,8 +213,8 @@ public void TestMessageIntegrityAttributeForBindingRequest() Assert.Equal(6, stunMessage.Attributes.Count); Assert.Equal("69-64-38-2B-4C-45-44-57-4D-31-64-30", BitConverter.ToString(stunMessage.Header.TransactionId)); - stunMessage.Attributes.Remove(stunMessage.Attributes.Where(x => x.AttributeType == STUNAttributeTypesEnum.MessageIntegrity).Single()); - stunMessage.Attributes.Remove(stunMessage.Attributes.Where(x => x.AttributeType == STUNAttributeTypesEnum.FingerPrint).Single()); + stunMessage.Attributes.Remove(stunMessage.Attributes.Single(x => x.AttributeType == STUNAttributeTypesEnum.MessageIntegrity)); + stunMessage.Attributes.Remove(stunMessage.Attributes.Single(x => x.AttributeType == STUNAttributeTypesEnum.FingerPrint)); byte[] buffer = stunMessage.ToByteBufferStringKey("r89XhWC9k2kW4Pns75vmwHIa", true);