public void AddNetworkConnector_SendMessage_Test()
        {
            bool eventFired = false;
            Guid clientGuid = new Guid();

            //Arrange
            NetworkConnectSystem system = NetworkConnectSystem.GetInstance();
            var connector = new StubINetworkConnector()
            {
                SendMessageRemResMessageGuid = (message, clientID) => { return(true); },
                IsClientRegisteredGuid       = (clientID) => clientGuid == clientID
            };

            system.AddNetworkConnector(connector);
            system.MessageReceived += (message, clientID) => { eventFired = true; };

            //network system start
            system.Start();

            //receive message from network connector
            connector.MessageReceivedEvent(new AddWatchRule(), clientGuid);

            //Assert
            //Send message Back
            Assert.IsTrue(eventFired);
            //Assert.IsTrue(system.SendMessage(new OperationStatus(), clientGuid));

            system.Stop();
        }
示例#2
0
        /// <summary>
        /// Initializes the network connect system.
        /// </summary>
        private void InitNetworkConnectSystem()
        {
            int servicePort = -1;

            //load instance of networkConnect system
            networkSystem = NetworkConnectSystem.GetInstance();

            //Get port from SettingsManager
            servicePort = LoadServicePort();

            //initialize the dataservice to save the notification enpoints
            networkSystem.NotificationDataService = new XmlNotificationDataService();

            //add network XML Connector or Listener
            networkSystem.AddNetworkConnector(new ServiceXmlListener(servicePort));
        }
        public void AddNetworkConnector_StartUp_Test()
        {
            bool eventFired = false;
            Guid clientGuid = new Guid();

            //Arrange
            NetworkConnectSystem system = NetworkConnectSystem.GetInstance();
            var connector = new StubINetworkConnector();

            system.AddNetworkConnector(connector);
            system.MessageReceived += (message, clientID) => { eventFired = true; };

            //network system start
            system.Start();

            //receive message from network connector
            connector.MessageReceivedEvent(new AddWatchRule(), clientGuid);

            //Assert
            Assert.IsTrue(eventFired);

            system.Stop();
        }