WaitForMessage() public method

public WaitForMessage ( int milisecondsTimeout = 1000 ) : void
milisecondsTimeout int
return void
示例#1
0
        public void BasicFileEndpointTest()
        {
            // A new application
            Application application = new Application();

            // Add endpoints
            string             filePath           = "test-file.txt";
            FileReaderEndpoint fileReaderEndpoint = new FileReaderEndpoint(filePath, 100, Encoding.Default);

            application.Ports.Add(new Port {
                Endpoint = fileReaderEndpoint
            });

            string             fileOutPath        = "test-file-out.txt";
            FileWriterEndpoint fileWriterEndpoint = new FileWriterEndpoint(fileOutPath, true, Encoding.Default, true);

            application.Ports.Add(new Port {
                Endpoint = fileWriterEndpoint
            });

            // Add a channel
            Channel channel = new Channel();

            application.Channels.Add(channel);

            // Source setup
            Source source = new Source();

            channel.Source = source;

            Destination destination = new Destination();

            destination.Target = fileWriterEndpoint;
            channel.Destinations.Add(destination);

            // Host
            ApplicationHost applicationHost = new ApplicationHost();

            applicationHost.Deploy(application);

            // Start the processing
            applicationHost.StartProcessing();
            fileReaderEndpoint.WaitForMessage();
            fileReaderEndpoint.WaitForMessage();

            // Check that endpoint wrote the message

            using (StreamReader reader = new StreamReader(fileOutPath))
            {
                string text = reader.ReadToEnd();
                Assert.AreEqual("Hello world!\nHello world!", text.Trim().Replace("\r\n", "\n"));
                reader.Close();
            }
        }
		public void BasicFileEndpointTest()
		{
			// A new application
			Application application = new Application();

			// Add endpoints
			string filePath = "test-file.txt";
			FileReaderEndpoint fileReaderEndpoint = new FileReaderEndpoint(filePath, 100, Encoding.Default);
			application.Ports.Add(new Port { Endpoint = fileReaderEndpoint });

			string fileOutPath = "test-file-out.txt";
			FileWriterEndpoint fileWriterEndpoint = new FileWriterEndpoint(fileOutPath, true, Encoding.Default, true);
			application.Ports.Add(new Port { Endpoint = fileWriterEndpoint });

			// Add a channel
			Channel channel = new Channel();
			application.Channels.Add(channel);

			// Source setup
			Source source = new Source();
			channel.Source = source;

			Destination destination = new Destination();
			destination.Target = fileWriterEndpoint;
			channel.Destinations.Add(destination);

			// Host
			ApplicationHost applicationHost = new ApplicationHost();
			applicationHost.Deploy(application);

			// Start the processing
			applicationHost.StartProcessing();
			fileReaderEndpoint.WaitForMessage();
			fileReaderEndpoint.WaitForMessage();

			// Check that endpoint wrote the message

			using (StreamReader reader = new StreamReader(fileOutPath))
			{
				string text = reader.ReadToEnd();
				Assert.AreEqual("Hello world!\nHello world!", text.Trim().Replace("\r\n", "\n"));
				reader.Close();
			}
		}