Exemple #1
0
        public void IsReplyRequiredTest()
        {
            SlpServiceAgent target = new SlpServiceAgent()
            {
                ServiceUrl = "service:e133.esta://2.4.3.127/0xaabb11223344"
            };
            ServiceRequestPacket request = new ServiceRequestPacket()
            {
                ServiceType = "service:e133.esta", Scope = target.Scope
            };

            Assert.IsTrue(target.IsReplyRequired(request));
            request.ServiceType = "service:directory-agent";
            Assert.IsFalse(target.IsReplyRequired(request));

            request.ServiceType = "service:e133.esta";
            target.ServiceUrl   = "service:printer:lpr://igore.wco.ftp.com:515/draft";
            Assert.IsFalse(target.IsReplyRequired(request));
            request.ServiceType = "service:printer";
            Assert.IsTrue(target.IsReplyRequired(request));
            request.ServiceType = "service:lpr";
            Assert.IsTrue(target.IsReplyRequired(request));
            request.ServiceType = "service:printer:lpr";
            Assert.IsTrue(target.IsReplyRequired(request));

            request.ServiceType = "service:print6er";
            Assert.IsFalse(target.IsReplyRequired(request));
            request.ServiceType = "service:lp2r";
            Assert.IsFalse(target.IsReplyRequired(request));
            request.ServiceType = "service:prin4ter:lpr";
            Assert.IsFalse(target.IsReplyRequired(request));
            request.ServiceType = "service:printer:lp9r";
            Assert.IsFalse(target.IsReplyRequired(request));
        }
Exemple #2
0
 public void CheckUrlMatchTest()
 {
     Assert.IsFalse(SlpServiceAgent.CheckUrlMatch("", "", "", ""));
     Assert.IsTrue(SlpServiceAgent.CheckUrlMatch("service:printer:lpr://igore.wco.ftp.com:515/draft", "printer", "lpr", "igore.wco.ftp.com:515/draft"));
     Assert.IsFalse(SlpServiceAgent.CheckUrlMatch("service:printer:lpr://igore.wco.ftp.com:515/draft", "printer", "lpr", "10.0.0.1:515/draft"));
     Assert.IsFalse(SlpServiceAgent.CheckUrlMatch("service:printer:lpr://igore.wco.ftp.com:515/draft", "e133.esta", "lpr", "igore.wco.ftp.com:515/draft"));
     Assert.IsTrue(SlpServiceAgent.CheckUrlMatch("service:e133.esta", "e133.esta", string.Empty, "2.4.9.8:5568/0xaabb11223344"));
     Assert.IsTrue(SlpServiceAgent.CheckUrlMatch("service:e133.esta://2.4.9.8:5568/0xaabb11223344", "e133.esta", string.Empty, "2.4.9.8:5568/0xaabb11223344"));
     Assert.IsFalse(SlpServiceAgent.CheckUrlMatch("service:e133.esta://2.7.9.8:5568/0xaabb11223344", "e133.esta", string.Empty, "2.4.9.8:5568/0xaabb11223344"));
     Assert.IsTrue(SlpServiceAgent.CheckUrlMatch("nfs://max.net/znoo", "filestore", "nfs", "max.net/znoo"));
     Assert.IsFalse(SlpServiceAgent.CheckUrlMatch("nfs://max.org/znoo", "filestore", "nfs", "max.net/znoo"));
 }
Exemple #3
0
        public void ServiceUrlTest_Concrete()
        {
            SlpServiceAgent target   = new SlpServiceAgent();
            string          expected = "http://www.ietf.org:80/rfc";
            string          actual;

            target.ServiceUrl = expected;
            actual            = target.ServiceUrl;
            Assert.AreEqual("service:http://www.ietf.org:80/rfc", actual, "Full service url did not match when parsed and output");
            Assert.AreEqual <string>("service:http", target.ServiceType, "Full service type did not match");
            Assert.AreEqual <string>(string.Empty, target.ServiceAbstractType, "Abstract service type did not match");
            Assert.AreEqual <string>("http", target.ServiceConcreteType, "Concrete service type did not match");
            Assert.AreEqual <string>("www.ietf.org:80/rfc", target.ServiceAddress, "Address service type did not match");
        }
Exemple #4
0
        public void ServiceUrlTest_AcnUrls()
        {
            SlpServiceAgent target   = new SlpServiceAgent();
            string          expected = "service:e133.esta://2.4.3.127/0xaabb11223344";
            string          actual;

            target.ServiceUrl = expected;
            actual            = target.ServiceUrl;
            Assert.AreEqual(expected, actual, "Full service url did not match when parsed and output");
            Assert.AreEqual <string>("service:e133.esta", target.ServiceType, "Full service type did not match");
            Assert.AreEqual <string>("e133.esta", target.ServiceAbstractType, "Abstract service type did not match");
            Assert.AreEqual <string>(string.Empty, target.ServiceConcreteType, "Concrete service type did not match");
            Assert.AreEqual <string>("2.4.3.127/0xaabb11223344", target.ServiceAddress, "Address service type did not match");
        }
Exemple #5
0
        public void ServiceUrlTest()
        {
            SlpServiceAgent target   = new SlpServiceAgent();
            string          expected = "service:printer:lpr://igore.wco.ftp.com:515/draft";
            string          actual;

            target.ServiceUrl = expected;
            actual            = target.ServiceUrl;
            Assert.AreEqual(expected, actual, "Full service url did not match when parsed and output");
            Assert.AreEqual <string>("service:printer:lpr", target.ServiceType, "Full service type did not match");
            Assert.AreEqual <string>("printer", target.ServiceAbstractType, "Abstract service type did not match");
            Assert.AreEqual <string>("lpr", target.ServiceConcreteType, "Concrete service type did not match");
            Assert.AreEqual <string>("igore.wco.ftp.com:515/draft", target.ServiceAddress, "Address service type did not match");
        }
Exemple #6
0
        void manager_DevicesUpdated(object sender, EventArgs e)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new EventHandler(manager_DevicesUpdated));
                return;
            }
            devicesGrid.Rows.Clear();
            foreach (var device in manager.GetDevices())
            {
                devicesGrid.Rows.Add(
                    device.Url,
                    SlpServiceAgent.JoinAttributeString(device.Attributes),
                    device.LastContact,
                    device.State.ToString()
                    );
                Color backColour = Color.White;

                switch (device.State)
                {
                case SlpDeviceState.New:
                    backColour = Color.LightGreen;
                    break;

                case SlpDeviceState.MissedPoll:
                    backColour = Color.Yellow;
                    break;

                case SlpDeviceState.Disappeared:
                    backColour = Color.Red;
                    break;

                case SlpDeviceState.ReAppeared:
                    backColour = Color.Green;
                    break;
                }

                devicesGrid.Rows[devicesGrid.Rows.Count - 1].DefaultCellStyle.BackColor = backColour;
            }
        }