IceCandidateTest.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using NUnit.Framework;
  3. namespace Unity.WebRTC.RuntimeTest
  4. {
  5. class IceCandidateTest
  6. {
  7. [SetUp]
  8. public void SetUp()
  9. {
  10. WebRTC.Initialize(true);
  11. }
  12. [TearDown]
  13. public void TearDown()
  14. {
  15. WebRTC.Dispose();
  16. }
  17. [Test]
  18. public void Construct()
  19. {
  20. Assert.Throws<ArgumentException>(() => new RTCIceCandidate());
  21. }
  22. [Test]
  23. public void ConstructWithOption()
  24. {
  25. var option = new RTCIceCandidateInit
  26. {
  27. sdpMid = "0",
  28. sdpMLineIndex = 0,
  29. candidate =
  30. "candidate:102362043 1 udp 2122262783 240b:10:2fe0:4900:3cbd:7306:63c4:a8e1 50241 typ host generation 0 ufrag DEIG network-id 5"
  31. };
  32. var candidate = new RTCIceCandidate(option);
  33. Assert.IsNotEmpty(candidate.Candidate);
  34. Assert.AreEqual(candidate.Candidate, option.candidate);
  35. Assert.AreEqual(candidate.SdpMLineIndex, option.sdpMLineIndex);
  36. Assert.AreEqual(candidate.SdpMid, option.sdpMid);
  37. Assert.AreEqual(RTCIceComponent.Rtp, candidate.Component);
  38. Assert.IsNotEmpty(candidate.Foundation);
  39. Assert.NotNull(candidate.Port);
  40. Assert.NotNull(candidate.Priority);
  41. Assert.IsNotEmpty(candidate.Address);
  42. Assert.NotNull(candidate.Protocol);
  43. Assert.IsNotEmpty(candidate.RelatedAddress);
  44. Assert.NotNull(candidate.RelatedPort);
  45. Assert.IsNotEmpty(candidate.SdpMid);
  46. Assert.NotNull(candidate.SdpMLineIndex);
  47. Assert.NotNull(candidate.Type);
  48. Assert.Null(candidate.TcpType);
  49. Assert.IsNotEmpty(candidate.UserNameFragment);
  50. }
  51. }
  52. }