ProfileTester.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using Emby.Dlna;
  2. using Emby.Dlna.PlayTo;
  3. using MediaBrowser.Common.Configuration;
  4. using MediaBrowser.Controller;
  5. using MediaBrowser.Model.Dlna;
  6. using MediaBrowser.Model.IO;
  7. using MediaBrowser.Model.Serialization;
  8. using Microsoft.Extensions.Logging;
  9. using Moq;
  10. using Xunit;
  11. namespace Jellyfin.Dlna.Tests
  12. {
  13. public class DlnaManagerTests
  14. {
  15. private DlnaManager GetManager()
  16. {
  17. var xmlSerializer = new Mock<IXmlSerializer>();
  18. var fileSystem = new Mock<IFileSystem>();
  19. var appPaths = new Mock<IApplicationPaths>();
  20. var loggerFactory = new Mock<ILoggerFactory>();
  21. var appHost = new Mock<IServerApplicationHost>();
  22. return new DlnaManager(xmlSerializer.Object, fileSystem.Object, appPaths.Object, loggerFactory.Object, appHost.Object);
  23. }
  24. [Fact]
  25. public void IsMatch_GivenMatchingName_ReturnsTrue()
  26. {
  27. var device = new DeviceInfo()
  28. {
  29. Name = "My Device",
  30. Manufacturer = "LG Electronics",
  31. ManufacturerUrl = "http://www.lge.com",
  32. ModelDescription = "LG WebOSTV DMRplus",
  33. ModelName = "LG TV",
  34. ModelNumber = "1.0",
  35. };
  36. var profile = new DeviceProfile()
  37. {
  38. Name = "Test Profile",
  39. FriendlyName = "My Device",
  40. Manufacturer = "LG Electronics",
  41. ManufacturerUrl = "http://www.lge.com",
  42. ModelDescription = "LG WebOSTV DMRplus",
  43. ModelName = "LG TV",
  44. ModelNumber = "1.0",
  45. Identification = new DeviceIdentification()
  46. {
  47. FriendlyName = "My Device",
  48. Manufacturer = "LG Electronics",
  49. ManufacturerUrl = "http://www.lge.com",
  50. ModelDescription = "LG WebOSTV DMRplus",
  51. ModelName = "LG TV",
  52. ModelNumber = "1.0",
  53. }
  54. };
  55. Assert.True(GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification));
  56. var profile2 = new DeviceProfile()
  57. {
  58. Name = "Test Profile",
  59. FriendlyName = "My Device",
  60. Identification = new DeviceIdentification()
  61. {
  62. FriendlyName = "My Device",
  63. }
  64. };
  65. Assert.True(GetManager().IsMatch(device.ToDeviceIdentification(), profile2.Identification));
  66. }
  67. [Fact]
  68. public void IsMatch_GivenNamesAndManufacturersDoNotMatch_ReturnsFalse()
  69. {
  70. var device = new DeviceInfo()
  71. {
  72. Name = "My Device",
  73. Manufacturer = "JVC"
  74. };
  75. var profile = new DeviceProfile()
  76. {
  77. Name = "Test Profile",
  78. FriendlyName = "My Device",
  79. Manufacturer = "LG Electronics",
  80. ManufacturerUrl = "http://www.lge.com",
  81. ModelDescription = "LG WebOSTV DMRplus",
  82. ModelName = "LG TV",
  83. ModelNumber = "1.0",
  84. Identification = new DeviceIdentification()
  85. {
  86. FriendlyName = "My Device",
  87. Manufacturer = "LG Electronics",
  88. ManufacturerUrl = "http://www.lge.com",
  89. ModelDescription = "LG WebOSTV DMRplus",
  90. ModelName = "LG TV",
  91. ModelNumber = "1.0",
  92. }
  93. };
  94. Assert.False(GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification));
  95. }
  96. }
  97. }