Beispiel #1
0
        private void MessageContractStreamInOutService()
        {
            IMessageContractStreamInReturnService clientProxy = GetProxy <IMessageContractStreamInReturnService>();
            MessageContractStreamNoHeader         input       = ClientHelper.GetMessageContractStreamNoHeader(TestString);
            MessageContractStreamOneIntHeader     output      = clientProxy.Operation(input);
            string response = ClientHelper.GetStringFrom(output.input);

            Assert.Equal(TestString, response);
        }
Beispiel #2
0
        private void ReturnFileStreamService()
        {
            IMessageContractStreamInReturnService clientProxy = GetProxy <IMessageContractStreamInReturnService>();
            MessageContractStreamNoHeader         message     = new MessageContractStreamNoHeader
            {
                stream = ClientHelper.GetStreamWithStringBytes(TestString)
            };

            using (Stream stream = clientProxy.Operation(message).input)
            {
                long      size = 0, read = 0;
                const int BUFFER = 1000;
                byte[]    buffer = new byte[BUFFER];
                do
                {
                    read  = stream.Read(buffer, 0, BUFFER);
                    size += read;
                } while (read > 0);

                FileStream file = File.OpenRead("temp.dat");
                Assert.Equal(file.Length, size);
            }
        }
Beispiel #3
0
        private void InFileStreamService()
        {
            IMessageContractStreamInReturnService clientProxy = GetProxy <IMessageContractStreamInReturnService>();

            if (!File.Exists(FileToSend))
            {
                throw new FileNotFoundException("Could not find file " + FileToSend);
            }

            using (FileStream file = File.OpenRead(FileToSend))
            {
                long fileLength = file.Length;
                _output.WriteLine("File size is " + fileLength);
                Stream input   = file;
                var    message = new MessageContractStreamNoHeader
                {
                    stream = input
                };
                MessageContractStreamOneIntHeader output = clientProxy.Operation(message);
                string response = ClientHelper.GetStringFrom(output.input);
                long   size     = long.Parse(response);
                Assert.Equal(fileLength, size);
            }
        }