static RPCHelloClient() { NetTcpBinding tcpBinding = new NetTcpBinding(); EndpointAddress tcpAddr = new EndpointAddress("net.tcp://192.168.187.1:8083/Hello"); tcpBinding.Security.Mode = SecurityMode.None;//与服务端保持一致 proxy = new ChannelFactory<IHello>(tcpBinding, tcpAddr).CreateChannel(); }
static void Main(string[] args) { HproseClient client = HproseClient.Create("tcp4://127.0.0.1:4321/"); hello = client.UseService<IHello>(); Console.WriteLine("TCP"); Console.WriteLine(hello.Hello("World")); Test("World"); Test("".PadRight(512, '$')); Test("".PadRight(1024, '$')); Test("".PadRight(2 * 1024, '$')); Test("".PadRight(4 * 1024, '$')); Test("".PadRight(8 * 1024, '$')); Test("".PadRight(16 * 1024, '$')); Test("".PadRight(32 * 1024, '$')); Test("".PadRight(64 * 1024, '$')); client = HproseClient.Create("http://localhost:8888/"); hello = client.UseService<IHello>(); Console.WriteLine("HTTP"); Console.WriteLine(hello.Hello("World")); Test("World"); Test("".PadRight(512, '$')); Test("".PadRight(1024, '$')); Test("".PadRight(2 * 1024, '$')); Test("".PadRight(4 * 1024, '$')); Test("".PadRight(8 * 1024, '$')); Test("".PadRight(16 * 1024, '$')); Test("".PadRight(32 * 1024, '$')); Test("".PadRight(64 * 1024, '$')); Console.ReadKey(); // client.Invoke<string>("hello", new Object[] { "Async World" }, result => Console.WriteLine(result)); }
public void RpcCall_10000() { RpcFactory anRpcFactory = new RpcFactory(mySerializer); IRpcService <IHello> anRpcService = anRpcFactory.CreateSingleInstanceService <IHello>(new HelloService()); IRpcClient <IHello> anRpcClient = anRpcFactory.CreateClient <IHello>(); try { anRpcService.AttachDuplexInputChannel(myMessaging.CreateDuplexInputChannel(myChannelId)); anRpcClient.AttachDuplexOutputChannel(myMessaging.CreateDuplexOutputChannel(myChannelId)); IHello aServiceProxy = anRpcClient.Proxy; Stopwatch aStopWatch = new Stopwatch(); aStopWatch.Start(); //EneterTrace.StartProfiler(); for (int i = 0; i < 10000; ++i) { aServiceProxy.Sum(1, 2); } //EneterTrace.StopProfiler(); aStopWatch.Stop(); Console.WriteLine("Rpc call. Elapsed time = " + aStopWatch.Elapsed); HelloService aService = new HelloService(); Stopwatch aStopWatch2 = new Stopwatch(); aStopWatch2.Start(); for (int i = 0; i < 10000; ++i) { aService.Sum(1, 2); } aStopWatch2.Stop(); Console.WriteLine("Local call. Elapsed time = " + aStopWatch2.Elapsed); } finally { if (anRpcClient.IsDuplexOutputChannelAttached) { anRpcClient.DetachDuplexOutputChannel(); } if (anRpcService.IsDuplexInputChannelAttached) { anRpcService.DetachDuplexInputChannel(); } } }
static void Main(string[] args) { using (ChannelFactory <IHello> channelFactoryHello = new ChannelFactory <IHello>("helloService")) using (ChannelFactory <IGoodbye> channelFactoryGoodbye = new ChannelFactory <IGoodbye>("goodbyeService")) { IHello helloProxy = channelFactoryHello.CreateChannel(); IGoodbye goodbyeProxy = channelFactoryGoodbye.CreateChannel(); Console.WriteLine(helloProxy.SayHello("Zhang San")); Console.WriteLine(goodbyeProxy.SayGoodbye("Li Si")); } }
static void Main() { AppDomain domain = AppDomain.CreateDomain("Test"); // @MDB LINE: main IHello hello = (IHello)domain.CreateInstanceAndUnwrap("TestAppDomain-Hello", "Hello"); hello.World(); // @MDB LINE: main2 AppDomain.Unload(domain); // @MDB BREAKPOINT: unload Console.WriteLine("UNLOADED!"); // @MDB LINE: end }
public ActionResult Index() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); IHello client = RPCClientFactory.GetClient <IHello>("127.0.0.1", 39999); client.SayHello("aa"); stopwatch.Stop(); return(Content(stopwatch.ElapsedMilliseconds.ToString())); }
public void RemoteObj(string name) { Console.WriteLine("\nTo create an instance of IHello"); Type objtype = Type.GetTypeFromProgID("HelloCS.HelloImp", true); IHello obj = (HelloCS.IHello)Activator.CreateInstance(objtype); // it works by accessing an COM+ object. Console.WriteLine("\nTo call obj.HelloWorld() with arg = " + name); string reply = obj.HelloWorld(name); Console.WriteLine("the reply = " + reply); }
public static void Main() { Hello <int> hello = new Hello <int> (); hello.Print(5); hello.Test <float> ().Print(3.14F); IHello <string> foo = hello.Test <string> (); foo.Print("World"); }
private static TimeSpan Run(string name, TimeSpan baseTime, IHello hello) { var sw = Stopwatch.StartNew(); for (int i = 0; i < Iterations; i++) { hello.Hello(); } var time = sw.Elapsed; Console.WriteLine(name + ": " + time + ", slowdown: " + time.TotalMilliseconds / baseTime.TotalMilliseconds); return time; }
public void InitializeHostAndClient() { host = new ServiceHost(typeof(HelloService)); host.AddServiceEndpoint(typeof(IHello), new NetNamedPipeBinding(), "net.pipe://localhost/hello"); host.Open(); client = ChannelFactory<IHello>.CreateChannel(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/hello")); }
static void Main(string[] args) { using (ChannelFactory <IHello> helloFactory = new ChannelFactory <IHello>("helloService")) using (ChannelFactory <IGoodBye> goodbyeFactory = new ChannelFactory <IGoodBye>("goodbyeService")) { IHello hello = helloFactory.CreateChannel(); IGoodBye goodBye = goodbyeFactory.CreateChannel(); Console.WriteLine(hello.SayHello("z3")); Console.WriteLine(goodBye.SayGoodBye("w5")); } Console.Read(); }
public void RpcGenericEvent() { RpcFactory anRpcFactory = new RpcFactory(mySerializer); HelloService aService = new HelloService(); IRpcService <IHello> anRpcService = anRpcFactory.CreateSingleInstanceService <IHello>(aService); IRpcClient <IHello> anRpcClient = anRpcFactory.CreateClient <IHello>(); try { anRpcService.AttachDuplexInputChannel(myMessaging.CreateDuplexInputChannel(myChannelId)); anRpcClient.AttachDuplexOutputChannel(myMessaging.CreateDuplexOutputChannel(myChannelId)); IHello aServiceProxy = anRpcClient.Proxy; AutoResetEvent anEventReceived = new AutoResetEvent(false); Action <object, OpenArgs> anEventHandler = (x, y) => { anEventReceived.Set(); }; // Subscribe. aServiceProxy.Open += anEventHandler.Invoke; // Raise the event in the service. OpenArgs anOpenArgs = new OpenArgs() { Name = "Hello" }; aService.RaiseOpen(anOpenArgs); Assert.IsTrue(anEventReceived.WaitOne()); // Unsubscribe. aServiceProxy.Open -= anEventHandler.Invoke; // Try to raise again. aService.RaiseOpen(anOpenArgs); Assert.IsFalse(anEventReceived.WaitOne(1000)); } finally { if (anRpcClient.IsDuplexOutputChannelAttached) { anRpcClient.DetachDuplexOutputChannel(); } if (anRpcService.IsDuplexInputChannelAttached) { anRpcService.DetachDuplexInputChannel(); } } }
public override async Task OnActivateAsync() { Log.Debug($"{typeof(MainEntryGrain)}OnActivateAsync"); m_ChatRoom = await GetIChatRoom(); m_IGateWay = await GetIGateWay(); m_IHello = GrainFactory.GetGrain <IHello>(0); RegisterTimer(Update_Timer, null, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)); await base.OnActivateAsync(); }
public ActionResult Index() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); IHello client = RPCClientFactory.GetClient <IHello>("127.0.0.1", 39999); client.SayHello("aa"); stopwatch.Stop(); var ms = (double)stopwatch.ElapsedTicks / 10000; return(Content($"{ms}ms")); }
private static TimeSpan Run(string name, TimeSpan baseTime, IHello hello) { var sw = Stopwatch.StartNew(); for (int i = 0; i < Iterations; i++) { hello.Hello(); } var time = sw.Elapsed; Console.WriteLine(name + ": " + time + ", slowdown: " + time.TotalMilliseconds / baseTime.TotalMilliseconds); return(time); }
static void Main(string[] args) { IHello hello = null; string[] cities = { "Dorne", "Winterfell", "TheEyrie", "KingsLanding", "Dragonstone", "CasterlyRock" }; foreach (string city in cities) { var type = Type.GetType(city + ".Hello" + city + "," + city); hello = (IHello)Activator.CreateInstance(type); hello.SayHello(); } }
static void Main(string[] args) { IHello hello = null; hello = new HelloBraavos(); hello.SayHello(); hello = new HelloVaesDothrak(); hello.SayHello(); hello = new HelloMeereen(); hello.SayHello(); }
public async Task SiloSayHelloTest() { long id = new Random().Next(); const string greeting = "Bonjour"; IHello grain = await Silo.CreateGrainAsync <HelloGrain>(id); // This will create and call a Hello grain with specified 'id' in one of the test silos. string reply = await grain.SayHello(greeting); Assert.NotNull(reply); Assert.Equal($"You said: '{greeting}', I say: Hello!", reply); }
static void Main(string[] args) { Console.WriteLine("--------------------------------------------------------------------------------------"); Console.WriteLine("欢迎测试任务调度"); Console.WriteLine("指令说明:"); Console.WriteLine("1.停止Tibos任务,2.停止Test任务"); Console.WriteLine("3.启动Tibos任务,4.启动Test任务"); Console.WriteLine("5.启动全部任务 ,6.停止全部任务"); Console.WriteLine("--------------------------------------------------------------------------------------"); IHello client = RPCClientFactory.GetClient <IHello>("127.0.0.1", 9988); var instruction = ""; while (instruction != "0") { Console.WriteLine("请输入指令!"); instruction = Console.ReadLine(); switch (instruction) { case "1": client.PauseJobAsync("job", "group4"); break; case "2": client.PauseJobAsync("job4", "group4"); break; case "3": client.ResumeAsync("job", "group4"); break; case "4": client.ResumeAsync("job4", "group4"); break; case "5": client.ResumeAllAsync(); break; case "6": client.PauseAllAsync(); break; default: break; } } Console.WriteLine("游戏结束!"); Console.ReadLine(); }
public async Task SiloSayHelloTest() { // The Orleans silo / client test environment is already set up at this point. long id = new Random().Next(); const string greeting = "Bonjour"; IHello grain = GrainFactory.GetGrain <IHello>(id); // This will create and call a Hello grain with specified 'id' in one of the test silos. string reply = await grain.SayHello(greeting); Assert.NotNull(reply); Assert.Equal($"You said: '{greeting}', I say: Hello!", reply); }
static async Task Main(string[] args) { client = new XRPCClient("localhost", 9090); client.Options.ParameterFormater = new JsonPacket();//default messagepack hello = client.Create <IHello>(); while (true) { Console.Write("Enter you name:"); var name = Console.ReadLine(); var result = await hello.Hello(name); Console.WriteLine(result); } Console.Read(); }
static void Call(ChannelFactory <IHello> factory, string address, Uri serviceVia) { IHello channel = factory.CreateChannel(new EndpointAddress(address), serviceVia); try { string reply = channel.Hello(); Console.WriteLine(reply.ToString()); ((IClientChannel)channel).Close(); } catch (CommunicationException ce) { Console.WriteLine("Exception: {0}", ce.Message); ((IClientChannel)channel).Abort(); } }
public async Task SayHelloTest() { // The Orleans silo / client test environment is already set up at this point. const long id = 0; const string greeting = "Bonjour"; IHello grain = GrainFactory.GetGrain <IHello>(id); // This will create and call a Hello grain with specified 'id' in one of the test silos. string reply = await grain.SayHello(greeting); Assert.IsNotNull(reply, "Grain replied with some message"); string expected = string.Format("You said: '{0}', I say: Hello!", greeting); Assert.AreEqual(expected, reply, "Grain replied with expected message"); }
static void Test1() { Console.WriteLine("----Test1"); try { Hello <int> hello = new Hello <int>(); hello.Print(5); hello.Test <float>().Print(3.14F); IHello <string> foo = hello.Test <string>(); foo.Print("World"); } catch (Exception e) { Console.WriteLine("error" + e); } }
public async void NonSiloSayHelloTest() { // The mocked Orleans runtime is already set up at this point const long id = 0; const string greeting = "Bonjour"; //Create a new instance of the grain. Notice this is the concrete grain type //that is being tested, not just the grain interface as with the silo test IHello grain = TestGrainFactory.CreateGrain <HelloGrain>(id); // This will directly call the grain under test. string reply = await grain.SayHello(greeting); Assert.NotNull(reply); Assert.Equal($"You said: '{greeting}', I say: Hello!", reply); }
static void RpcTest() { int port = 9999; int count = 1; int errorCount = 0; RPCServer rPCServer = new RPCServer(port); rPCServer.HandleException = ex => { Console.WriteLine(ExceptionHelper.GetExceptionAllMsg(ex)); }; rPCServer.RegisterService <IHello, Hello>(); rPCServer.Start(); IHello client = null; client = RPCClientFactory.GetClient <IHello>("127.0.0.1", port); client.SayHello("aaa"); Stopwatch watch = new Stopwatch(); List <Task> tasks = new List <Task>(); watch.Start(); LoopHelper.Loop(1, () => { tasks.Add(Task.Run(() => { LoopHelper.Loop(count, () => { string msg = string.Empty; try { msg = client.SayHello("Hello"); Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")}:{msg}"); } catch (Exception ex) { Console.WriteLine(ExceptionHelper.GetExceptionAllMsg(ex)); } }); })); }); Task.WaitAll(tasks.ToArray()); watch.Stop(); Console.WriteLine($"每次耗时:{(double)watch.ElapsedMilliseconds / count}ms"); Console.WriteLine($"错误次数:{errorCount}"); }
public void Test() { AssemblyName asmName = new AssemblyName(); asmName.Name = "HelloWorld"; AssemblyBuilder asmBuilder = Thread.GetDomain().DefineDynamicAssembly(asmName, AssemblyBuilderAccess.RunAndSave); ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule("HelloWorld"); TypeBuilder typeBuilder = modBuilder.DefineType( "Hello", TypeAttributes.Public, typeof(object), new Type[] { typeof(IHello) }); MethodBuilder methodBuilder = typeBuilder.DefineMethod("SayHello", MethodAttributes.Private | MethodAttributes.Virtual, typeof(void), new Type[] { typeof(string) }); typeBuilder.DefineMethodOverride(methodBuilder, typeof(IHello).GetMethod("SayHello")); ILGenerator il = methodBuilder.GetILGenerator(); // string.Format("Hello, {0} World!", toWhom) // /*[a]*/ il.Emit/*[/a]*/ (OpCodes.Ldstr, "Hello, {0} World!"); /*[a]*/ il.Emit/*[/a]*/ (OpCodes.Ldarg_1); /*[a]*/ il.Emit/*[/a]*/ (OpCodes.Call, typeof(string).GetMethod("Format", new Type[] { typeof(string), typeof(object) })); // Console.WriteLine("Hello, World!"); // /*[a]*/ il.Emit/*[/a]*/ (OpCodes.Call, typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) })); /*[a]*/ il.Emit/*[/a]*/ (OpCodes.Ret); Type type = typeBuilder.CreateType(); IHello hello = (IHello)Activator.CreateInstance(type); hello.SayHello("Emit"); }
static void DotNettyRPCTest() { int threadCount = 1; int port = 9999; int count = 10000; int errorCount = 0; RPCServer rPCServer = new RPCServer(port); rPCServer.RegisterService <IHello, Hello>(); rPCServer.Start(); IHello client = null; client = RPCClientFactory.GetClient <IHello>("127.0.0.1", port); client.SayHello("aaa"); Stopwatch watch = new Stopwatch(); List <Task> tasks = new List <Task>(); watch.Start(); for (int i = 0; i < threadCount; i++) { tasks.Add(Task.Run(() => { for (int j = 0; j < count; j++) { string msg = string.Empty; try { //msg = client.SayHello("Hello"); //Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")}:{msg}"); } catch (Exception ex) { errorCount++; //Console.WriteLine(ExceptionHelper.GetExceptionAllMsg(ex)); } } })); } Task.WaitAll(tasks.ToArray()); watch.Stop(); Console.WriteLine($"并发数:{threadCount},运行:{count}次,每次耗时:{(double)watch.ElapsedMilliseconds / count}ms"); Console.WriteLine($"错误次数:{errorCount}"); }
public async Task SayHelloTest() { // The Orleans silo / client test environment is already set up at this point. const long id = 0; const string name = "David"; IHello grain = GrainFactory.GetGrain <IHello>(id); // This will create and call a Hello grain with specified 'id' in one of the test silos. string reply = await grain.SayHello(name); Console.WriteLine(reply); Assert.IsNotNull(reply, "Grain replied with some message"); string expected = string.Format("Hello, David! Goodbye, David!", name); Assert.AreEqual(expected, reply, "Grain replied with expected message"); }
static void Main() { TcpChannel channel = new TcpChannel(); ChannelServices.RegisterChannel(channel, true); IHello obj = (IHello)Activator.GetObject( typeof(IHello), "tcp://localhost:8086/HelloService"); if (obj == null) { System.Console.WriteLine("Could not locate server"); } else { Console.WriteLine(obj.Hello()); } Console.ReadLine(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IHello hello, ILogger <Startup> logger) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); //app.UseMvcWithDefaultRoute(); app.UseMvc(ConfigureRoutes); app.Map("/test", testPipeline); // app.Run(async (context) => // { // //await context.Response.WriteAsync("Hello World!"); // // await context.Response.WriteAsync(hello.SayHello()); // logger.LogInformation("Response Served"); // await context.Response.WriteAsync(hello.SayHello()); // }); }
private static void Main(string[] args) { if (args.Length > 0) { for (;;) { IHello friend = ActorProxy.Create <IHello>(ActorId.NewId(), ApplicationName); Console.WriteLine(@"\n\nFrom Actor {1}: {0}\n\n", friend.SayHello("Good morning!").Result, friend.GetActorId()); Thread.Sleep(50); } } else { IHello friend = ActorProxy.Create <IHello>(ActorId.NewId(), ApplicationName); Console.WriteLine(@"\n\nFrom Actor {1}: {0}\n\n", friend.SayHello("Good morning!").Result, friend.GetActorId()); } Console.WriteLine(@"Press enter to exit ..."); Console.ReadLine(); }
public void WebMessageFormats() { var host = new WebServiceHost(typeof(Hello)); host.AddServiceEndpoint(typeof(IHello), new WebHttpBinding(), "http://localhost:37564/"); host.Open(); try { // run client using (ChannelFactory <IHello> factory = new ChannelFactory <IHello> (new WebHttpBinding(), "http://localhost:37564/")) { factory.Endpoint.Behaviors.Add(new WebHttpBehavior()); IHello h = factory.CreateChannel(); //Console.WriteLine(h.SayHi("Joe", 42, null)); Assert.AreEqual("Hi Joe.", h.SayHi2(new User { Name = "Joe" }), "#1"); } } finally { host.Close(); } }
protected async void ButtonSayHello_Click(object sender, EventArgs e) { this.ReplyText.Text = "Talking to Orleans"; IHello grainRef = GrainFactory.GetGrain <IHello>(0); try { string msg = await grainRef.SayHello(this.NameTextBox.Text); this.ReplyText.Text = "Orleans said: " + msg + " at " + DateTime.UtcNow + " UTC"; } catch (Exception exc) { while (exc is AggregateException) { exc = exc.InnerException; } this.ReplyText.Text = "Error connecting to Orleans: " + exc + " at " + DateTime.Now; } }
public HelloApplication(IHello words, IVoice voice) { this.Words = words; this.Voice = voice; }
public SampleJob(IHello hello) { this.hello = hello; }
public int DoIt2(string a, int b, DateTime time, Class2 class2, IHello helloParam) { return a.Length + b; }
private static void runTests(IHello hello) { #region AddValue { Console.Write(" AddValue: "); check(5 == hello.AddValue(2, 3)); } #endregion #region SayHello { Console.Write(" SayHello: "); check("Hello, Andy. It's Bob." == hello.SayHello("Andy")); } #endregion #region SayHello2 { Console.Write(" SayHello2: "); string greeting; hello.SayHello2("Andy", out greeting); check("Hello, Andy. It's Bob." == greeting); } #endregion #region Message { Console.Write(" Message: "); string message = "Hello, Bob"; bool result = hello.Message(ref message); check(result && ("Hello, Andy." == message)); } #endregion #region MulComplex { Console.Write(" MulComplex: "); MyComplexNumber x = new MyComplexNumber(2, 3); MyComplexNumber y = new MyComplexNumber(5, 6); MyComplexNumber expected = new MyComplexNumber(x.re * y.re - x.im * y.im, x.re * y.im + x.im - y.re); MyComplexNumber result = hello.MulComplex(x, ref y); check(equal(result, expected) && equal(result, expected)); } try { Console.Write(" MulComplexAsAny: "); MyComplexNumber x = new MyComplexNumber(2, 3); MyComplexNumber y = new MyComplexNumber(5, 6); MyComplexNumber expected = new MyComplexNumber(x.re * y.re - x.im * y.im, x.re * y.im + x.im - y.re); object result; bool success = hello.MulComplexAsAny(x, y, out result); MyComplexNumber complexNumber = (MyComplexNumber)result; check(success && equal(complexNumber, expected)); } catch (System.Exception) { Console.WriteLine("__NOT RELEVANT__: Known issue with IIOP.NET marshalling <-> omniORB unmarshsalling of 'Any' type"); } #endregion #region TimeTransfer { Console.Write(" DataTimeTransfer: "); DateTime dateTime = new DateTime(2016, 2, 8); long dataTimeValue = dateTime.ToFileTimeUtc(); hello.DataTimeTransfer(ref dataTimeValue); DateTime fromServer = DateTime.FromFileTimeUtc(dataTimeValue); check(dateTime == fromServer); } #endregion #region Exception hadlers Console.WriteLine(" Install exceptions hadlers: Not relevant in iiop.net"); #endregion #region System Exception try { Console.Write(" Catch NO_IMPLEMENT: "); hello.ThrowExceptions(0); } catch (NO_IMPLEMENT se) { check(1 == se.Minor); } catch (Exception) { check(false); } #endregion #region Plain user exception try { Console.Write(" Catch plain user exception: "); hello.ThrowExceptions(1); } catch (UserExceptionS ue) { check(ue.Message.Contains("UserExceptionS")); } catch (Exception) { check(false); } #endregion #region User exception with members try { Console.Write(" Catch user exception with members: "); hello.ThrowExceptions(2); } catch (UserExceptionExt ue) { check(ue.reason == "EXCEPTIONS_WORKS" && ue.codeError == 254); } catch (Exception) { check(false); } #endregion #region Unknown exception try { Console.Write(" Catch unknown exception: "); hello.ThrowExceptions(4); } catch (omg.org.CORBA.UNKNOWN e) { check(e.Message.Contains("UNKNOWN")); } catch (Exception) { check(false); } #endregion #region callback try { Console.WriteLine(" Callback: "); TestCallBack callback = new TestCallBack(); check(hello.CallMe(callback) && callback.Greeting == "Hello from Server"); } catch (Exception) { check(false); } #endregion #region sequense try { Console.Write(" Sequence reversed: "); int[] array = { 1, 3, 5, 7, 10 }; int[] reversed_arr = hello.Reverse(array); check(System.Linq.Enumerable.SequenceEqual(new int[] { 10, 7, 5, 3, 1 }, reversed_arr)); } catch (Exception) { check(false); } #endregion #region Pass single dimensional array try { Console.Write(" Pass single dimensional array: "); double[] x = { 1.0, 2.0, 3, 4.1}; double[] y = { 2.0, 7.0, -0, -9}; double[] expected = { x[0] + y[0], x[1] + y[1], x[2] + y[2], x[3] + y[3] }; double[] result = hello.AddVectors(x, y); check(result[0] == expected[0] && result[1] == expected[1] && result[2] == expected[2] && result[3] == expected[3]); } catch (Exception) { check(false); } #endregion #region Pass multi dimensional array try { Console.Write(" Pass multi dimensional array: "); double[,] x = { { 1.0, -2.0, 3, 4.1 }, { 2.0, 4.0, -6, 8.1 }, { -3.0, -5.0, 7, -1 } }; double[,] y = { { 3.0, -2.4, 3, -0 }, { 6.0, 2.0, -7, 8.9 }, { -7.0, -1.0, 7, 1 } }; double[,] expected = { { x[0, 0] + y[0, 0], x[0, 1] + y[0, 1], x[0, 2] + y[0, 2], x[0, 3] + y[0, 3]}, { x[1, 0] + y[1, 0], x[1, 1] + y[1, 1], x[1, 2] + y[1, 2], x[1, 3] + y[1, 3]}, { x[2, 0] + y[2, 0], x[2, 1] + y[2, 1], x[2, 2] + y[2, 2], x[2, 3] + y[2, 3]} }; double[,] result = hello.AddMatrixes(x, y); //check selectively check(result[0, 0] == expected[0, 0] && result[1,3] == expected[1, 3] && result[2, 0] == expected[2, 0] && result[2, 3] == expected[2, 3]); } catch (Exception) { check(false); } #endregion #region Shutdown try { Console.Write(" Shutdown: "); hello.Shutdown(); check(true); } catch (Exception) { check(false); } #endregion }