public void DeviceDefinition() { var validator = new Upnp10DeviceValidator(); var errors = validator .GetValidationErrors(DiscoveryService.DeviceDefinition.Value) .ToList(); Assert.True( !errors.Any(), string.Join(',', errors) ); }
public void UPnP10DeviceValidator_FailsDeviceTypeNamespaceOverMaxLength() { var rootDevice = new SsdpRootDevice() { FriendlyName = "Basic Device 1", Manufacturer = "Test Manufacturer", ManufacturerUrl = new Uri("http://testmanufacturer.com"), ModelDescription = "A test model device", ModelName = "Test Model", ModelNumber = "Model #1234", ModelUrl = new Uri("http://modelurl.com"), SerialNumber = "SN-123", Uuid = System.Guid.NewGuid().ToString(), Location = new Uri("http://testdevice:1700/xml"), }; var testDevice = new SsdpEmbeddedDevice() { DeviceType = "TestEmbeddedDevice", FriendlyName = "Embedded Device 1", DeviceTypeNamespace = new String('A', 65), Manufacturer = "Test Manufacturer", ManufacturerUrl = new Uri("http://testmanufacturer.com"), ModelDescription = "A test model device", ModelName = "Test Model", ModelNumber = "Model #1234", ModelUrl = new Uri("http://modelurl.com"), SerialNumber = "SN-123", Uuid = System.Guid.NewGuid().ToString(), }; rootDevice.AddDevice(testDevice); var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.IsTrue(results.First().IndexOf("DeviceTypeNamespace", StringComparison.OrdinalIgnoreCase) >= 0); }
public void UPnP10DeviceValidator_FailsNegativeWidth() { var rootDevice = new SsdpRootDevice() { FriendlyName = "Basic Device 1", Manufacturer = "Test Manufacturer", ManufacturerUrl = new Uri("http://testmanufacturer.com"), ModelDescription = "A test model device", ModelName = "Test Model", ModelNumber = "Model #1234", ModelUrl = new Uri("http://modelurl.com"), SerialNumber = "SN-123", Uuid = System.Guid.NewGuid().ToString(), Location = new Uri("http://testdevice:1700/xml"), }; var testDevice = new SsdpEmbeddedDevice() { DeviceType = "TestEmbeddedDevice", FriendlyName = "Embedded Device 1", DeviceTypeNamespace = "testdevice-org", Manufacturer = "Test Manufacturer", ManufacturerUrl = new Uri("http://testmanufacturer.com"), ModelDescription = "A test model device", ModelName = "Test Model", ModelNumber = "Model #1234", ModelUrl = new Uri("http://modelurl.com"), SerialNumber = "SN-123", Uuid = System.Guid.NewGuid().ToString() }; rootDevice.AddDevice(testDevice); var icon = new SsdpDeviceIcon() { ColorDepth = 32, Width = -1, Height = 48, MimeType = "image/png", Url = new Uri("someimage.png", UriKind.Relative) }; testDevice.Icons.Add(icon); var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); Assert.IsTrue(results.First().IndexOf("width", StringComparison.OrdinalIgnoreCase) >= 0); }
public void UPnP10DeviceValidator_UpcCodeIsOptional() { var rootDevice = new SsdpRootDevice() { FriendlyName = "Basic Device 1", Manufacturer = "Test Manufacturer", ManufacturerUrl = new Uri("http://testmanufacturer.com"), ModelDescription = "A test model device", ModelName = "Test Model", ModelNumber = "Model #1234", ModelUrl = new Uri("http://modelurl.com"), SerialNumber = "SN-123", Uuid = System.Guid.NewGuid().ToString(), Location = new Uri("http://testdevice:1700/xml") }; var testDevice = new SsdpEmbeddedDevice() { DeviceType = "TestEmbeddedDevice", FriendlyName = "Embedded Device 1", Manufacturer = "Test Manufacturer", ManufacturerUrl = new Uri("http://testmanufacturer.com"), ModelDescription = "A test model device", ModelName = "Test Model", ModelNumber = "Model #1234", ModelUrl = new Uri("http://modelurl.com"), SerialNumber = "SN-123", Uuid = System.Guid.NewGuid().ToString(), Upc = null }; rootDevice.AddDevice(testDevice); var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(0, results.Count()); }
public void UPnP10DeviceValidator_ThrowsOnNullRootDevice() { SsdpRootDevice testDevice = null; var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); }
public void UPnP10DeviceValidator_ThrowIfInvalidThrowsOnValidationError() { var testDevice = new SsdpRootDevice() { FriendlyName = "Basic Device 1", Manufacturer = "Test Manufacturer", ManufacturerUrl = new Uri("http://testmanufacturer.com"), ModelDescription = "A test model device", ModelName = "Test Model", ModelNumber = "Model #1234", ModelUrl = new Uri("http://modelurl.com"), SerialNumber = "SN-123", Uuid = null, Location = new Uri("http://testdevice:1700/xml") }; var validator = new Upnp10DeviceValidator(); validator.ThrowIfDeviceInvalid(testDevice); }
public void UPnP10DeviceValidator_ThrowIfInvalidThrowsOnNullRootDevice() { SsdpRootDevice testDevice = null; var validator = new Upnp10DeviceValidator(); validator.ThrowIfDeviceInvalid(testDevice); }
public void UPnP10DeviceValidator_RootDeviceRequiresLocation() { var testDevice = new SsdpRootDevice() { FriendlyName = "Basic Device 1", Manufacturer = "Test Manufacturer", ManufacturerUrl = new Uri("http://testmanufacturer.com"), ModelDescription = "A test model device", ModelName = "Test Model", ModelNumber = "Model #1234", ModelUrl = new Uri("http://modelurl.com"), SerialNumber = "SN-123", Uuid = System.Guid.NewGuid().ToString() }; var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); Assert.IsTrue(results.First().IndexOf("location", StringComparison.OrdinalIgnoreCase) >= 0); }
public void UPnP10DeviceValidator_FailsUpcCodeMoreThan12Chars() { var rootDevice = new SsdpRootDevice() { FriendlyName = "Basic Device 1", Manufacturer = "Test Manufacturer", ManufacturerUrl = new Uri("http://testmanufacturer.com"), ModelDescription = "A test model device", ModelName = "Test Model", ModelNumber = "Model #1234", ModelUrl = new Uri("http://modelurl.com"), SerialNumber = "SN-123", Uuid = System.Guid.NewGuid().ToString(), Location = new Uri("http://testdevice:1700/xml") }; var testDevice = new SsdpEmbeddedDevice() { DeviceType = "TestEmbeddedDevice", FriendlyName = "Embedded Device 1", Manufacturer = "Test Manufacturer", ManufacturerUrl = new Uri("http://testmanufacturer.com"), ModelDescription = "A test model device", ModelName = "Test Model", ModelNumber = "Model #1234", ModelUrl = new Uri("http://modelurl.com"), SerialNumber = "SN-123", Uuid = System.Guid.NewGuid().ToString(), Upc = "1234567890123" }; rootDevice.AddDevice(testDevice); var validator = new Upnp10DeviceValidator(); var results = validator.GetValidationErrors(testDevice); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count()); Assert.IsTrue(results.First().IndexOf("UPC", StringComparison.OrdinalIgnoreCase) >= 0); }