Beispiel #1
0
        public void RunHost()
        {
            _tester = new Mock<INetTester>();

            _tester
                .Setup(o => o.Min(It.IsAny<int>(), It.IsAny<int>()))
                .Returns((int a, int b) => Math.Min(a, b));

            _tester
                .Setup(o => o.Range(It.IsAny<int>(), It.IsAny<int>()))
                .Returns((int a, int b) => Enumerable.Range(a, b).ToDictionary(key => key, el => el));

            _ipAddress = IPAddress.Parse("127.0.0.1");

            _tcphost = new TcpHost(CreateEndPoint());
            _tcphost.AddService<INetTester>(_tester.Object);
            _tcphost.Open();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var logger = new Logger(logLevel: LogLevel.Debug);
            var stats = new Stats();

            var ip = ConfigurationManager.AppSettings["ip"];
            var port = Convert.ToInt32(ConfigurationManager.AppSettings["port"]);
            var ipEndpoint = new IPEndPoint(IPAddress.Any, port);

            var useCompression = false;
            var compressionThreshold = 131072; //128KB
            var pipeName = "ServiceWireTestHost";

            var nphost = new NpHost(pipeName, logger, stats);
            var tester = new NetTester();
            nphost.AddService<INetTester>(tester);
            var mytester = new MyTester();
            nphost.UseCompression = useCompression;
            nphost.CompressionThreshold = compressionThreshold;
            nphost.AddService<IMyTester>(mytester);
            nphost.Open();

            var tcphost = new TcpHost(ipEndpoint, logger, stats);
            tcphost.UseCompression = useCompression;
            tcphost.CompressionThreshold = compressionThreshold;
            tcphost.AddService<INetTester>(tester);
            tcphost.AddService<IMyTester>(mytester);

            var valTypes = new ValTypes();
            tcphost.AddService<IValTypes>(valTypes);

            tcphost.Open();

            Console.WriteLine("Press Enter to stop the dual host test.");
            Console.ReadLine();

            nphost.Close();
            tcphost.Close();

            Console.WriteLine("Press Enter to quit.");
            Console.ReadLine();
        }