예제 #1
0
        public async Task TestUploadCrossAsync()
        {
            GlobalInitalization.Initialize();
            ITestServerStreamModel service = new SignalGoTest2Services.StreamServices.TestServerStreamModel("localhost", 1132);

            using (MemoryStream memoryStream = new MemoryStream())
            {
                byte[] bytes = new byte[1024 * 512];
                for (int i = 0; i < bytes.Length; i++)
                {
                    bytes[i] = (byte)(i / 255);
                }
                memoryStream.Write(bytes, 0, bytes.Length);
                memoryStream.Seek(0, SeekOrigin.Begin);
                string result = await service.UploadImageAsync("hello world", new SignalGo.Shared.Models.StreamInfo()
                {
                    Length = memoryStream.Length,
                    Stream = memoryStream
                }, new TestStreamModel()
                {
                    Name = "test name", Values = new System.Collections.Generic.List <string>()
                    {
                        "value test 1", "value test 2"
                    }
                });

                Assert.IsTrue(result == "success");
            }
        }
예제 #2
0
        public void TestDownloadCross()
        {
            GlobalInitalization.Initialize();
            ITestServerStreamModel service = new SignalGoTest2Services.StreamServices.TestServerStreamModel("localhost", 1132);

            SignalGo.Shared.Models.StreamInfo <string> result = service.DownloadImage("hello world", new TestStreamModel()
            {
                Name = "test name", Values = new System.Collections.Generic.List <string>()
                {
                    "value test 1", "value test 2"
                }
            });
            byte[] bytes   = new byte[1024];
            int    readLen = result.Stream.ReadAsync(bytes, 1024).GetAwaiter().GetResult();

            System.Diagnostics.Trace.Assert(result.Data == "hello return" && readLen == 4 && bytes[0] == 2 && bytes[1] == 5 && bytes[2] == 8 && bytes[3] == 9);
        }