コード例 #1
0
        public EventingServiceController(string serviceTransportAddress)
        {
            this.serviceTransportAddress = serviceTransportAddress;

            // Set this device property if you want to ignore this service notifications
            this.IgnoreRequestFromThisIP = false;

            // Assigning either a static or random endpoint address will
            // init the transport address of this client which we will use soon
            this.EndpointAddress = "urn:uuid:" + Guid.NewGuid();

            // Adding a event handler
            this.ServiceOperations.Add(new WsServiceOperation(c_namespaceUri, // namespace
                                                              "SimpleEvent")); // event (method) name

            // Subscribe to the event
            DpwsServiceType subscriptionType = new DpwsServiceType("SimpleEvent", c_namespaceUri);
            DpwsSubscribeRequest request = new DpwsSubscribeRequest(subscriptionType, // subscription type
                                                                    serviceTransportAddress, // event source address
                                                                    this.TransportAddress, // notify to address
                                                                    null, // expires
                                                                    null // event identifier
                                                                    );
               this.EventingClient.Subscribe(request);
        }
コード例 #2
0
ファイル: DpwsClient.cs プロジェクト: yisea123/NETMF-LPC
 /// <summary>
 /// Removes the first occurrence of a specific DpwsServiceType from the collection.
 /// </summary>
 /// <param name="serviceType">
 /// The DpwsServiceType to remove from the collection.
 /// The value can be null.
 /// </param>
 public void Remove(DpwsServiceType serviceType)
 {
     lock (m_threadLock)
     {
         m_serviceTypes.Remove(serviceType);
     }
 }
コード例 #3
0
ファイル: DpwsClient.cs プロジェクト: yisea123/NETMF-LPC
 /// <summary>
 /// Adds a DpwsServiceType to the end of the collection.
 /// </summary>
 /// <param name="value">
 /// The DpwsServiceType element to be added to the end of the collection.
 /// The value can be null.
 /// </param>
 /// <returns>
 /// The collection index at which the DpwsServiceType has been added.
 /// </returns>
 public int Add(DpwsServiceType value)
 {
     lock (m_threadLock)
     {
         return(m_serviceTypes.Add(value));
     }
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: meikeric/DotCopter
        /// <summary>
        /// Looks for devices that host a service identified by its type and namespace. 
        /// It returns the transport address of the first matching service.
        /// </summary>
        public static string FindFirst(DpwsDiscoveryClient discoveryClient, string serviceTypeName, string namespaceUri)
        {
            if (discoveryClient == null)
                throw new ArgumentNullException();
            if (serviceTypeName == null)
                throw new ArgumentNullException();
            if (namespaceUri == null)
                throw new ArgumentNullException();

            Debug.Print("Discovering service devices...");
            // Define search criterias
            DpwsServiceType serviceType = new DpwsServiceType(serviceTypeName, namespaceUri);
            DpwsServiceTypes filters = new DpwsServiceTypes();
            filters.Add(serviceType);
            // Probe for devices
            DpwsServiceDescriptions probeMatches = discoveryClient.Probe(filters);
            if (probeMatches != null && probeMatches.Count > 0)
            {
                // Remember transport address of the first device
                string deviceTransportAddress = probeMatches[0].XAddrs[0];
                // Request metadata to get the desired service and its ID
                DpwsMexClient mexClient = new DpwsMexClient();
                DpwsMetadata metadata = mexClient.Get(deviceTransportAddress);
                // Check host service
                DpwsMexService host = metadata.Relationship.Host;
                if (host != null) // has host service
                {
                    if (host.ServiceTypes[serviceTypeName] != null)
                        return host.EndpointRefs[0].Address.AbsoluteUri;
                }
                // Check hosted services
                DpwsMexServices hostedServices = metadata.Relationship.HostedServices;
                if (hostedServices != null)
                {
                    for (int i = 0; i < hostedServices.Count; ++i)
                    {
                        DpwsMexService hostedService = hostedServices[i];
                        if (hostedService.ServiceTypes[serviceTypeName] != null)
                            return hostedService.EndpointRefs[0].Address.AbsoluteUri;
                    }
                }
            }
            Debug.Print("No service found.");
            return null;
        }
コード例 #5
0
        public void PrintProbeMatchInfo()
        {
            Debug.Print("Discovering service devices...");
            // Define search criterias
            DpwsServiceType serviceType = new DpwsServiceType("SimpleServiceType2", // type name
                                                              "http://schemas.sample.org/SimpleService2"); // namespace URI
            DpwsServiceTypes filters = new DpwsServiceTypes();
            filters.Add(serviceType);
            // Probe for devices
            DpwsServiceDescriptions probeMatches = this.DiscoveryClient.Probe(filters);
            if (probeMatches != null)
            {
                for (int i = 0; i < probeMatches.Count; ++i)
                {
                    DpwsServiceDescription probeMatch = probeMatches[i];
                    // Print probe match information
                    Debug.Print("");
                    Debug.Print("Probe Match:");

                    Debug.Print("Endpoint Address = " + probeMatch.Endpoint.Address.AbsoluteUri);

                    Debug.Print("Types:");
                    for (int t = 0; t < probeMatch.ServiceTypes.Count; ++t)
                    {
                        DpwsServiceType matchType = probeMatch.ServiceTypes[t];
                        Debug.Print("\tName = " + matchType.TypeName);
                        Debug.Print("\tNamespace = " + matchType.NamespaceUri);
                        Debug.Print("");
                    }

                    Debug.Print("XAddrs:");
                    foreach (string xaddr in probeMatch.XAddrs)
                        Debug.Print("\tTransport Address = " + xaddr);

                    Debug.Print("Metadata Version = " + probeMatch.MetadataVersion);
                }
            }
            else
                Debug.Print("No service device found.");
        }
コード例 #6
0
 /// <summary>
 /// Removes the first occurrence of a specific DpwsServiceType from the collection.
 /// </summary>
 /// <param name="serviceType">
 /// The DpwsServiceType to remove from the collection.
 /// The value can be null.
 /// </param>
 public void Remove(DpwsServiceType serviceType)
 {
     lock (m_threadLock)
     {
         m_serviceTypes.Remove(serviceType);
     }
 }
コード例 #7
0
 /// <summary>
 /// Adds a DpwsServiceType to the end of the collection.
 /// </summary>
 /// <param name="value">
 /// The DpwsServiceType element to be added to the end of the collection.
 /// The value can be null.
 /// </param>
 /// <returns>
 /// The collection index at which the DpwsServiceType has been added.
 /// </returns>
 public int Add(DpwsServiceType value)
 {
     lock (m_threadLock)
     {
         return m_serviceTypes.Add(value);
     }
 }
コード例 #8
0
        void SimpleServiceClient_HelloEvent(object obj, DpwsServiceDescription helloEventArgs)
        {
            m_receivedHelloEvent = true;
            DpwsMetadata m_mexDetails = null;

            try
            {
                // Print Hello information
                //Log.Comment("");
                //Log.Comment("SimpleService received a hello request.");
                ////Log.Comment("Endpoint address: " + helloEventArgs.Endpoint.Address.AbsoluteUri);
                string types = "";
                int count = helloEventArgs.ServiceTypes.Count;
                for (int i = 0; i < count; i++)
                {
                    DpwsServiceType type = helloEventArgs.ServiceTypes[i];
                    types += "NamespaceUri: " + type.NamespaceUri + " " + "TypeName: " + type.TypeName + "\n";
                }
                ////Log.Comment("Types: " + types);

                if (helloEventArgs.XAddrs != null)
                {
                    foreach (String xaddr in helloEventArgs.XAddrs)
                    {
                        ////Log.Comment("Xaddrs: " + xaddr);
                    }
                }

                ////Log.Comment("Metadata version: " + helloEventArgs.MetadataVersion);
                ////Log.Comment("");

                // Probe for services. For each valid probe match, print service information.
                DpwsServiceType searchType = new DpwsServiceType("SimpleService", "http://schemas.example.org/SimpleService");
                DpwsServiceTypes searchTypes = new DpwsServiceTypes();

                searchTypes.Add(searchType);

                // Accept the first 10 found within the first 10 seconds
                DpwsServiceDescriptions probeMatches = this.DiscoveryClient.Probe(searchTypes, 1, 10000);

                // retry
                if (probeMatches.Count == 0)
                {
                    probeMatches = this.DiscoveryClient.Probe(searchTypes, 1, 10000);
                }

                if (probeMatches != null)
                {
                    // Print the probe match information
                    ////Log.Comment("**********************");
                    ////Log.Comment("ProbeMatches received: " + probeMatches.Count);
                    int probeMatchCount = probeMatches.Count;
                    for (int i = 0; i < probeMatchCount; i++)
                    {
                        DpwsServiceDescription probeMatch = probeMatches[i];
                        ////Log.Comment("");
                        ////Log.Comment("ProbeMatch:");
                        ////Log.Comment("  Endpoint Address = " + probeMatch.Endpoint.Address.AbsoluteUri);
                        ////Log.Comment("  Types:");

                        PrintServiceTypes(probeMatch.ServiceTypes);

                        //////Log.Comment("  Xaddrs:");
                        //foreach (string xaddr in probeMatch.XAddrs)
                        //    //Log.Comment("    TransportAddress = " + xaddr);
                        ////Log.Comment("  Metadata Version = " + probeMatch.MetadataVersion);

                        // Resolve this endpoint
                        DpwsServiceDescription resolveMatch = this.DiscoveryClient.Resolve(probeMatch.Endpoint.Address.AbsoluteUri, 10000);
                        if (resolveMatch != null)
                        {
                            // Print resolve match information
                            ////Log.Comment("");
                            ////Log.Comment("ResolveMatch:");
                            ////Log.Comment("  Endpoint Address = " + resolveMatch.Endpoint.Address.AbsoluteUri);
                            ////Log.Comment("  Types:");

                            PrintServiceTypes(resolveMatch.ServiceTypes);

                            ////Log.Comment("  Xaddrs:");
                            //foreach (string xaddr in resolveMatch.XAddrs)
                            //    //Log.Comment("    TransportAddress = " + xaddr);

                            //Log.Comment("  Metadata Version = " + resolveMatch.MetadataVersion);

                            // For each Xaddr, get metadata
                            foreach (string xaddr in resolveMatch.XAddrs)
                            {
                                // Call Get
                                m_mexDetails = this.MexClient.Get(xaddr);

                                if (m_mexDetails == null)
                                {

                                    ////Log.Comment("Get failed. Address: " + xaddr);
                                }
                                else
                                {
                                    m_getMex = true;

                                    // Display metadata information
                                    ////Log.Comment("  Metadata:");
                                    ////Log.Comment("    ThisModel:");
                                    ////Log.Comment("      Manufacturer: " + m_mexDetails.ThisModel.Manufacturer);
                                    ////Log.Comment("      ManufacturerUrl: " + m_mexDetails.ThisModel.ManufacturerUrl);
                                    ////Log.Comment("      ModelName: " + m_mexDetails.ThisModel.ModelName);
                                    ////Log.Comment("      ModelNumber: " + m_mexDetails.ThisModel.ModelNumber);
                                    ////Log.Comment("      ModelUrl: " + m_mexDetails.ThisModel.ModelUrl);
                                    ////Log.Comment("      PresentationUrl: " + m_mexDetails.ThisModel.PresentationUrl);
                                    ////Log.Comment("    ThisDevice:");
                                    ////Log.Comment("      FirmwareVersion: " + m_mexDetails.ThisDevice.FirmwareVersion);
                                    ////Log.Comment("      FriendlyName: " + m_mexDetails.ThisDevice.FriendlyName);
                                    ////Log.Comment("      SerialNumber: " + m_mexDetails.ThisDevice.SerialNumber);
                                    if (m_mexDetails.Relationship.Host != null)
                                    {
                                        ////Log.Comment("    Host:");
                                        ////Log.Comment("      Service ID: " + m_mexDetails.Relationship.Host.ServiceID);
                                        ////Log.Comment("      Address: " + m_mexDetails.Relationship.Host.EndpointRefs[0].Address.AbsoluteUri);
                                        ////Log.Comment("      Types:");

                                        PrintServiceTypes(m_mexDetails.Relationship.Host.ServiceTypes);
                                    }
                                    if (m_mexDetails.Relationship.HostedServices != null)
                                    {
                                        ////Log.Comment("    HostedServices:");
                                        int hostedServiceCount = m_mexDetails.Relationship.HostedServices.Count;
                                        for (int j = 0; j < hostedServiceCount; j++)
                                        {
                                            DpwsMexService hostedService = m_mexDetails.Relationship.HostedServices[j];

                                            ////Log.Comment("      Service ID: " + hostedService.ServiceID);
                                            ////Log.Comment("      Address: " + hostedService.EndpointRefs[0].Address.AbsoluteUri);
                                            ////Log.Comment("      Types:");

                                            PrintServiceTypes(hostedService.ServiceTypes);
                                        }
                                    }
                                }
                            }

                            if (m_mexDetails != null)
                            {
                                // Look for the SimpleService in the HostedServices collection, create an HTTP
                                // client, call TwoWayRequest on the service endpoint, and display the result.
                                int hostedServiceCount = m_mexDetails.Relationship.HostedServices.Count;
                                for (int j = 0; j < hostedServiceCount; j++)
                                {
                                    DpwsMexService hostedService = m_mexDetails.Relationship.HostedServices[j];

                                    if (hostedService.ServiceTypes["SimpleService"] != null)    // found a SimpleService endpoint
                                    {
                                        string endpointAddress = hostedService.EndpointRefs[0].Address.AbsoluteUri;
                                        ////Log.Comment("");
                                        ////Log.Comment("Calling TwoWayRequest at endpoint: " + endpointAddress);

                                        // Create HttpClient and send request
                                        int x = 150;
                                        int y = 180;

                                        byte[] TwoWayRequest = Build2wayRequest(x, y, endpointAddress);

                                        
                                        //Log.Comment(new String(System.Text.Encoding.UTF8.GetChars(TwoWayRequest)));
                                        //DpwsHttpClient httpClient = new DpwsHttpClient();
                                        //DpwsSoapResponse response = httpClient.SendRequest(TwoWayRequest, endpointAddress, false, false);

                                        WsHttpClient httpClient = new WsHttpClient(m_version);
                                        WsMessage response = httpClient.SendRequest(new WsMessage(null, TwoWayRequest, WsPrefix.Wsdp), new Uri(endpointAddress));
                                        
                                        if (response != null)       // got a response
                                        {
                                            try
                                            {
                                                int sum = Parse2WayResponse(response.Header, response.Reader);
                                                //Log.Comment("");
                                                //Log.Comment("Received sum of " + sum.ToString() + " from " + endpointAddress);
                                                if ((x + y) == sum)
                                                    m_twoWay = true;
                                            }
                                            finally
                                            {
                                                response.Reader.Close();
                                            }
                                        }
                                    }
                                }
                            }
                            //Log.Comment("");
                        }
                    }
                }
            }
            finally
            {
            }

            if (m_mexDetails != null)
            {
                arHello.Set();
            }
        }
コード例 #9
0
ファイル: DiscoveryClient.cs プロジェクト: awakegod/NETMF-LPC
        /// <summary>
        /// Probe for a SimpleService endpoint.
        /// </summary>
        /// <param name="serviceAddress">A string containing the address of the simple service to find.</param>
        /// <returns>
        /// A DpwsMetadata object containing details about a SimpleService, null if
        /// a SImpleService is not found.
        /// </returns>
        public DpwsMetadata GetSimpleService(string serviceAddress)
        {
            // Resolve the service address
            m_dpwsClient.DiscoveryClient.ReceiveTimeout = 10000;
            DpwsServiceDescription resolveMatch = m_dpwsClient.DiscoveryClient.Resolve(serviceAddress);

            // Display results
            string serviceEndpoint = null;
            string targetService = null;
            if (resolveMatch != null)
            {
                // Print resolve match information
                System.Ext.Console.Write("");
                System.Ext.Console.Write("ResolveMatch:");
                System.Ext.Console.Write("  Endpoint Address = " + resolveMatch.Endpoint.Address);
                System.Ext.Console.Write("  Types:");
                targetService = resolveMatch.Endpoint.Address.AbsoluteUri;
                for (int i = 0; i < resolveMatch.ServiceTypes.Count; ++i)
                {
                    System.Ext.Console.Write("    Name = " + resolveMatch.ServiceTypes[i].TypeName);
                    System.Ext.Console.Write("    Namespace = " + resolveMatch.ServiceTypes[i].NamespaceUri);
                }
                System.Ext.Console.Write("  Xaddrs:");
                foreach (string xaddr in resolveMatch.XAddrs)
                {
                    System.Ext.Console.Write("    TransportAddress = " + xaddr);

                    // Since there's no support for IPV6 look for IPV4 address
                    if (xaddr.IndexOf(':') != -1)
                    {
                        serviceEndpoint = xaddr;
                    }
                }

                System.Ext.Console.Write("  Metadata Version = " + resolveMatch.MetadataVersion);
            }
            else
            {
                System.Ext.Console.Write("");
                System.Ext.Console.Write("SimpleDeviceType at address: " + serviceAddress + " failed to resolve. Discovery aborted");
                return null;
            }

            // Mae sure we got an address
            if (serviceEndpoint == null)
            {
                System.Ext.Console.Write("");
                System.Ext.Console.Write("Resolve did not send an IPV4 xaddr. Discovery aborted.");
            }

            // Send DirectedProbe
            DpwsMetadata m_mexDetails = null;

            // Create an empty search types collection
            DpwsServiceTypes searchTypes = new DpwsServiceTypes();

            // Build a SimpleDeviceType search type
            DpwsServiceType searchType1 = new DpwsServiceType("SimpleService", "http://schemas.example.org/SimpleService");
            searchTypes.Add(searchType1);
            
            // Get the SimpleDeviceType service details
            // Note: Uncomment the next line to test DirectedProbe to any MF Dpws service
            // DpwsServiceDescriptions probeMatches = m_dpwsClient.DiscoveryClient.DirectedProbe(serviceEndpoint, m_dpwsClient.DiscoveryClient.DiscoVersion.WellKnownAddress, searchTypes);
            // Note: Uncomment the next line to test against a DiscoveryProxy
            // DpwsServiceDescriptions probeMatches = m_dpwsClient.DiscoveryClient.DirectedProbe(serviceEndpoint, targetService, searchTypes);
            DpwsServiceDescriptions probeMatches = m_dpwsClient.DiscoveryClient.Probe(searchTypes);
            if (probeMatches != null && probeMatches.Count > 0)
            {
                // Select the probe match
                DpwsServiceDescription probeMatch = probeMatches[0];

                // Note: Uncoment the following line to test DirectedResolve against any MF Dpws Service.
                // DpwsServiceDescription resolveMatch1 = m_dpwsClient.DiscoveryClient.DirectedResolve(probeMatch.XAddrs[0], m_dpwsClient.DiscoveryClient.DiscoVersion.WellKnownAddress, serviceAddress);

                // Print the probe match information
                System.Ext.Console.Write("**********************");
                System.Ext.Console.Write("ProbeMatch received: " + probeMatches.Count);
                System.Ext.Console.Write("");
                System.Ext.Console.Write("ProbeMatch:");
                System.Ext.Console.Write("  Endpoint Address = " + probeMatch.Endpoint.Address);
                System.Ext.Console.Write("  Types:");
                for (int i = 0; i < probeMatch.ServiceTypes.Count; ++i)
                {
                    System.Ext.Console.Write("    Name = " + probeMatch.ServiceTypes[i].TypeName);
                    System.Ext.Console.Write("    Namespace = " + probeMatch.ServiceTypes[i].NamespaceUri);
                }
                System.Ext.Console.Write("  Xaddrs:");
                foreach (string xaddr in probeMatch.XAddrs)
                    System.Ext.Console.Write("    TransportAddress = " + xaddr);
                System.Ext.Console.Write("  Metadata Version = " + probeMatch.MetadataVersion);
            }

            // If we had a probe match store the service endpoint and get metadata
            if (probeMatches != null)
            {
                m_dpwsClient.EndpointAddress = serviceAddress;
                m_mexDetails = m_dpwsClient.MexClient.Get(serviceEndpoint);

                if (m_mexDetails == null)
                {
                    System.Ext.Console.Write("");
                    System.Ext.Console.Write("Get did not receive metadata. Discovery aborted.");
                    return null;
                }
                // Display metadata information
                System.Ext.Console.Write("  Metadata:");
                System.Ext.Console.Write("    ThisModel:");
                System.Ext.Console.Write("      Manufacturer: " + m_mexDetails.ThisModel.Manufacturer);
                System.Ext.Console.Write("      ManufacturerUrl: " + m_mexDetails.ThisModel.ManufacturerUrl);
                System.Ext.Console.Write("      ModelName: " + m_mexDetails.ThisModel.ModelName);
                System.Ext.Console.Write("      ModelNumber: " + m_mexDetails.ThisModel.ModelNumber);
                System.Ext.Console.Write("      ModelUrl: " + m_mexDetails.ThisModel.ModelUrl);
                System.Ext.Console.Write("      PresentationUrl: " + m_mexDetails.ThisModel.PresentationUrl);
                System.Ext.Console.Write("    ThisDevice:");
                System.Ext.Console.Write("      FirmwareVersion: " + m_mexDetails.ThisDevice.FirmwareVersion);
                System.Ext.Console.Write("      FriendlyName: " + m_mexDetails.ThisDevice.FriendlyName);
                System.Ext.Console.Write("      SerialNumber: " + m_mexDetails.ThisDevice.SerialNumber);
                if (m_mexDetails.Relationship.Host != null)
                {
                    System.Ext.Console.Write("    Host:");
                    System.Ext.Console.Write("      Service ID: " + m_mexDetails.Relationship.Host.ServiceID);
                    System.Ext.Console.Write("      Address: " + m_mexDetails.Relationship.Host.EndpointRefs[0].Address.AbsoluteUri);
                    System.Ext.Console.Write("      Types:");
                    for (int i = 0; i < m_mexDetails.Relationship.Host.ServiceTypes.Count; ++i)
                    {
                        DpwsServiceType serviceType = m_mexDetails.Relationship.Host.ServiceTypes[i];
                        System.Ext.Console.Write("        Name: " + serviceType.TypeName);
                        System.Ext.Console.Write("        NamespaceUri: " + serviceType.NamespaceUri);
                    }
                }
                if (m_mexDetails.Relationship.HostedServices != null)
                {
                    System.Ext.Console.Write("    HostedServices:");
                    for (int i = 0; i < m_mexDetails.Relationship.HostedServices.Count; ++i)
                    {
                        DpwsMexService hostedService = m_mexDetails.Relationship.HostedServices[i];
                        System.Ext.Console.Write("      Service ID: " + hostedService.ServiceID);
                        System.Ext.Console.Write("      Address: " + hostedService.EndpointRefs[0].Address.AbsoluteUri);
                        System.Ext.Console.Write("      Types:");
                        for (int ii = 0; ii < hostedService.ServiceTypes.Count; ++ii)
                        {
                            System.Ext.Console.Write("        Type name: " + hostedService.ServiceTypes[ii].TypeName);
                            System.Ext.Console.Write("        NamespaceUri: " + hostedService.ServiceTypes[ii].NamespaceUri);
                        }
                    }
                }
            }
            return m_mexDetails;
        }
コード例 #10
0
ファイル: ClientTests.cs プロジェクト: awakegod/NETMF-LPC
        public MFTestResults ClientTest_DpwsServiceTypes()
        {
            /// <summary>
            /// 1. Verifies the properties of a DpwsServiceTypes object
            /// 2. Adds elements to it
            /// 3. Re-verifies
            /// 4. Empties the object
            /// 5. Re-verifies
            /// </summary>
            ///
            bool testResult = true;
            try
            {
                DpwsServiceTypes testDSTs = new DpwsServiceTypes();

                if (testDSTs.Count != 0)
                    throw new Exception("Count did not set correctly on new");

                testDSTs.Clear();

                if (testDSTs.Count != 0)
                    throw new Exception("Count did not set correctly after new ... clear");

                String typeName = "typeName";
                String namespaceUri = "namespaceUri";

                DpwsServiceType testDST1 = new DpwsServiceType(typeName, namespaceUri);

                String typeName2 = "typeName2";
                String namespaceUri2 = "namespaceUri2";

                DpwsServiceType testDST2 = new DpwsServiceType(typeName2, namespaceUri2);

                testDSTs.Add(testDST1);

                testDSTs.Add(testDST2);

                if (testDSTs.Count != 2)
                    throw new Exception("Count did not set correctly on new");


                testDSTs.Remove(testDST1);

                if (testDSTs.Count != 1)
                    throw new Exception("Count did not set correctly after remove");

                testDSTs.Clear();

                if (testDSTs.Count != 0)
                    throw new Exception("Count did not set correctly after new ... clear");
            }
            catch (Exception e)
            {
                testResult = false;
                Log.Comment("Incorrect exception caught: " + e.Message);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }
コード例 #11
0
ファイル: ClientTests.cs プロジェクト: awakegod/NETMF-LPC
        public MFTestResults ClientTest_DpwsServiceType()
        {
            /// <summary>
            /// 1. Verifies each of the proerties of a DpwsServiceType object
            /// </summary>
            ///

            bool testResult = true;
            try
            {
                String typeName = "typeName";
                String namespaceUri = "namespaceUri";

                DpwsServiceType testDST = new DpwsServiceType(typeName, namespaceUri);

                Log.Comment("NamespaceUri");
                if (testDST.NamespaceUri != null)
                    if (testDST.NamespaceUri.GetType() != Type.GetType("System.String"))
                        throw new Exception("NamespaceUri wrong type");

                if (testDST.NamespaceUri != namespaceUri)
                    throw new Exception("NamespaceUri bad data");


                Log.Comment("TypeName");
                if (testDST.TypeName != null)
                    if (testDST.TypeName.GetType() != Type.GetType("System.String"))
                        throw new Exception("TypeName wrong type");

                if (testDST.TypeName != typeName)
                    throw new Exception("TypeName bad data");

            }
            catch (Exception e)
            {
                testResult = false;
                Log.Comment("Incorrect exception caught: " + e.Message);
            }
            return (testResult ? MFTestResults.Pass : MFTestResults.Fail);
        }