ProfileTester.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7. using Emby.Dlna;
  8. using Emby.Dlna.PlayTo;
  9. using MediaBrowser.Model.Dlna;
  10. using Xunit;
  11. namespace Jellyfin.Dlna.Tests
  12. {
  13. public class ProfileTester
  14. {
  15. [Fact]
  16. public void Test_Profile_Matches()
  17. {
  18. var device = new DeviceInfo()
  19. {
  20. Name = "My Device",
  21. Manufacturer = "LG Electronics",
  22. ManufacturerUrl = "http://www.lge.com",
  23. ModelDescription = "LG WebOSTV DMRplus",
  24. ModelName = "LG TV",
  25. ModelNumber = "1.0",
  26. };
  27. var profile = new DeviceProfile()
  28. {
  29. Name = "Test Profile",
  30. FriendlyName = "My Device",
  31. Manufacturer = "LG Electronics",
  32. ManufacturerUrl = "http://www.lge.com",
  33. ModelDescription = "LG WebOSTV DMRplus",
  34. ModelName = "LG TV",
  35. ModelNumber = "1.0",
  36. Identification = new DeviceIdentification()
  37. {
  38. FriendlyName = "My Device",
  39. Manufacturer = "LG Electronics",
  40. ManufacturerUrl = "http://www.lge.com",
  41. ModelDescription = "LG WebOSTV DMRplus",
  42. ModelName = "LG TV",
  43. ModelNumber = "1.0",
  44. }
  45. };
  46. Assert.True(DlnaManager.IsMatch(device.ToDeviceIdentification(), profile.Identification));
  47. var profile2 = new DeviceProfile()
  48. {
  49. Name = "Test Profile",
  50. FriendlyName = "My Device",
  51. Identification = new DeviceIdentification()
  52. {
  53. FriendlyName = "My Device",
  54. }
  55. };
  56. Assert.True(DlnaManager.IsMatch(device.ToDeviceIdentification(), profile2.Identification));
  57. }
  58. [Fact]
  59. public void Test_Profile_NoMatch()
  60. {
  61. var device = new DeviceInfo()
  62. {
  63. Name = "My Device",
  64. Manufacturer = "JVC"
  65. };
  66. var profile = new DeviceProfile()
  67. {
  68. Name = "Test Profile",
  69. FriendlyName = "My Device",
  70. Manufacturer = "LG Electronics",
  71. ManufacturerUrl = "http://www.lge.com",
  72. ModelDescription = "LG WebOSTV DMRplus",
  73. ModelName = "LG TV",
  74. ModelNumber = "1.0",
  75. Identification = new DeviceIdentification()
  76. {
  77. FriendlyName = "My Device",
  78. Manufacturer = "LG Electronics",
  79. ManufacturerUrl = "http://www.lge.com",
  80. ModelDescription = "LG WebOSTV DMRplus",
  81. ModelName = "LG TV",
  82. ModelNumber = "1.0",
  83. }
  84. };
  85. Assert.False(DlnaManager.IsMatch(device.ToDeviceIdentification(), profile.Identification));
  86. }
  87. }
  88. }