Exemplo n.º 1
0
        public void SsdpDevicePropertiesCollection_Contains_PropertyWithNullNameThrows()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var p          = new SsdpDeviceProperty();

            properties.Contains(p);
        }
Exemplo n.º 2
0
        public void SsdpDevicePropertiesCollection_Add_NullFullNameThrows()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var p          = new SsdpDeviceProperty();

            properties.Add(p);
        }
Exemplo n.º 3
0
        public void DeviceProperty_FullNameIsCorrectWithNoNamespaceSpecified()
        {
            var prop = new SsdpDeviceProperty();

            prop.Name  = "TestPropName";
            prop.Value = "TestValue";

            Assert.AreEqual("TestPropName", prop.FullName);
        }
Exemplo n.º 4
0
        public void DeviceProperty_FullNameIsCorrectFormat()
        {
            var prop = new SsdpDeviceProperty();

            prop.Namespace = "TestNamespace";
            prop.Name      = "TestPropName";
            prop.Value     = "TestValue";

            Assert.AreEqual("TestNamespace:TestPropName", prop.FullName);
        }
Exemplo n.º 5
0
        public void SsdpDevicePropertiesCollection_Contains_PropertyWithEmptyNameThrows()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var p          = new SsdpDeviceProperty()
            {
                Name      = String.Empty,
                Namespace = String.Empty
            };

            properties.Contains(p);
        }
Exemplo n.º 6
0
        public void SsdpDevicePropertiesCollection_Add_EmptyFullNameThrows()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var p          = new SsdpDeviceProperty()
            {
                Name      = String.Empty,
                Namespace = String.Empty
            };

            properties.Add(p);
        }
Exemplo n.º 7
0
        private SsdpRootDevice CreateDeviceTree(SsdpDeviceProperty testHeader = null)
        {
            var retVal = CreateValidRootDevice();

            if (testHeader != null)
            {
                retVal.additionalSearchResponseProperties.Add(testHeader);
            }
            retVal.AddDevice(CreateValidEmbeddedDevice(retVal));
            retVal.Devices.First().AddDevice(CreateValidEmbeddedDevice(retVal));
            return(retVal);
        }
Exemplo n.º 8
0
        public void SsdpDevicePropertiesCollection_Count_ReturnsZeroAfterLastItemRemoved()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var prop       = new SsdpDeviceProperty()
            {
                Name      = "TestProperty",
                Namespace = "MyNamespace",
                Value     = "1.0"
            };

            properties.Remove(prop);
            Assert.AreEqual(0, properties.Count);
        }
Exemplo n.º 9
0
        public void SsdpDevicePropertiesCollection_Remove_RemoveByKeySucceeds()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var p          = new SsdpDeviceProperty()
            {
                Name      = "TestProp1",
                Namespace = "TestNamespace"
            };

            properties.Add(p);

            Assert.AreEqual(true, properties.Remove(p.FullName));
            Assert.AreEqual(0, properties.Count);
        }
Exemplo n.º 10
0
        public void SsdpDevicePropertiesCollection_Contains_ReturnsFalseForNonExistentKey()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var prop       = new SsdpDeviceProperty()
            {
                Name      = "TestProperty",
                Namespace = "MyNamespace",
                Value     = "1.0"
            };

            properties.Add(prop);

            Assert.AreEqual(false, properties.Contains("NotAValidKey"));
        }
Exemplo n.º 11
0
        public void SsdpDevicePropertiesCollection_Count_ReturnsOneAfterItemAdded()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var prop       = new SsdpDeviceProperty()
            {
                Name      = "TestProperty",
                Namespace = "MyNamespace",
                Value     = "1.0"
            };

            properties.Add(prop);

            Assert.AreEqual(1, properties.Count);
        }
Exemplo n.º 12
0
        public void SsdpDevicePropertiesCollection_Indexer_ThrowsOnUnknownKey()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var p          = new SsdpDeviceProperty()
            {
                Name      = "Test",
                Namespace = "TestNamespace",
                Value     = "some value"
            };

            properties.Add(p);

            Assert.AreEqual(p, properties["NotAValidKey"]);
        }
Exemplo n.º 13
0
        public void SsdpDevicePropertiesCollection_Indexer_Succeeds()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var p          = new SsdpDeviceProperty()
            {
                Name      = "Test",
                Namespace = "TestNamespace",
                Value     = "some value"
            };

            properties.Add(p);

            Assert.AreEqual(p, properties[p.FullName]);
        }
Exemplo n.º 14
0
        public void SsdpDevicePropertiesCollection_Contains_ReturnsTrueForExistingItem()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var prop       = new SsdpDeviceProperty()
            {
                Name      = "TestProperty",
                Namespace = "MyNamespace",
                Value     = "1.0"
            };

            properties.Add(prop);

            Assert.AreEqual(true, properties.Contains(prop));
        }
Exemplo n.º 15
0
        private SsdpRootDevice CreateSampleRootDevice()
        {
            var retVal = new SsdpRootDevice()
            {
                CacheLifetime       = TimeSpan.FromMinutes(30),
                DeviceType          = "TestDeviceType",
                DeviceTypeNamespace = "test-device-ns",
                FriendlyName        = "Test Device 1",
                Location            = new Uri("http://testdevice:1700"),
                Manufacturer        = "Test Manufacturer",
                ManufacturerUrl     = new Uri("http://testman.com"),
                ModelDescription    = "A test device",
                ModelName           = "Test Model",
                ModelNumber         = "1234",
                ModelUrl            = new Uri("http://testmodel.com"),
                PresentationUrl     = new Uri("http://testmodel.com/presentation"),
                SerialNumber        = "TM-12345",
                Upc     = "123456789012",
                UrlBase = new Uri("http://testdevice:1700"),
                Uuid    = Guid.NewGuid().ToString()
            };

            var customProp = new SsdpDeviceProperty()
            {
                Namespace = "custom-ns", Name = "TestProp1", Value = "Test"
            };

            retVal.CustomProperties.Add(customProp);
            customProp = new SsdpDeviceProperty()
            {
                Namespace = "custom-ns", Name = "TestProp2", Value = "Test"
            };
            retVal.CustomProperties.Add(customProp);

            var icon = new SsdpDeviceIcon()
            {
                ColorDepth = 32, Height = 48, Width = 48, MimeType = "image/png", Url = new Uri("icons/48", UriKind.Relative)
            };

            retVal.Icons.Add(icon);
            icon = new SsdpDeviceIcon()
            {
                ColorDepth = 32, Height = 120, Width = 120, MimeType = "image/png", Url = new Uri("icons/120", UriKind.Relative)
            };
            retVal.Icons.Add(icon);

            return(retVal);
        }
Exemplo n.º 16
0
        public void SsdpDevicePropertiesCollection_GetEnumerator_Success()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var prop       = new SsdpDeviceProperty()
            {
                Name      = "TestProperty",
                Namespace = "MyNamespace",
                Value     = "1.0"
            };

            properties.Add(prop);
            var enumerator = ((IEnumerable)properties).GetEnumerator();

            Assert.AreEqual(true, enumerator.MoveNext());
            Assert.AreEqual(prop, enumerator.Current);
            Assert.AreEqual(false, enumerator.MoveNext());
        }
Exemplo n.º 17
0
        public void SsdpDevicePropertiesCollection_Remove_RemoveInstanceForDifferentInstanceWithSameKeyReturnsFalse()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var p          = new SsdpDeviceProperty()
            {
                Name      = "TestProp1",
                Namespace = "TestNamespace"
            };

            var p2 = new SsdpDeviceProperty()
            {
                Name      = "TestProp1",
                Namespace = "TestNamespace"
            };

            properties.Add(p);

            Assert.AreEqual(false, properties.Remove(p2));
            Assert.AreEqual(1, properties.Count);
        }
Exemplo n.º 18
0
        public void SsdpDevicePropertiesCollection_Contains_ReturnsFalseForExistingKeyDifferentItem()
        {
            var properties = new SsdpDevicePropertiesCollection();
            var prop       = new SsdpDeviceProperty()
            {
                Name      = "TestProperty",
                Namespace = "MyNamespace",
                Value     = "1.0"
            };

            var prop2 = new SsdpDeviceProperty()
            {
                Name      = "TestProperty",
                Namespace = "MyNamespace",
                Value     = "1.0"
            };

            properties.Add(prop);

            Assert.AreEqual(false, properties.Contains(prop2));
        }