Ejemplo n.º 1
0
 public MultiplyOutput Multiply(MultiplyInput input)
 {
     var output = new MultiplyOutput();
     output.ResultNumber = input.FirstNumber*input.SecondNumber;
     output.ResultString = input.Prefix + output.ResultNumber;
     return output;
 }
Ejemplo n.º 2
0
        public void ParameterProtoTest()
        {
            MultiplyInput input = new MultiplyInput();

            input.FirstNumber  = 6;
            input.SecondNumber = 7;
            input.Prefix       = "the prefix";
            var memInputStream = new MemoryStream();

            ProtoBuf.Serializer.Serialize(memInputStream, input);

            MultiplyOutput output = new MultiplyOutput();

            output.ResultNumber = 42;
            output.ResultString = "the result";
            var memOutputStream = new MemoryStream();

            ProtoBuf.Serializer.Serialize(memOutputStream, output);

            resultMessage.CallResult.ProtoParam = memOutputStream.ToArray();
            MultiplyOutput x = service.Multiply(input);

            Assert.That(x.ResultNumber, Is.EqualTo(42));
            Assert.That(x.ResultString, Is.EqualTo("the result"));
            client.Verify(c => c.Call("ISampleService", "Multiply", It.Is <RpcMessage.Parameter[]>(
                                          p => p.Length == 1 && p[0].ProtoParam.SequenceEqual(memInputStream.ToArray())), null, null));
        }
Ejemplo n.º 3
0
        public MultiplyOutput Multiply(MultiplyInput input)
        {
            var output = new MultiplyOutput();

            output.ResultNumber = input.FirstNumber * input.SecondNumber;
            output.ResultString = input.Prefix + output.ResultNumber;
            return(output);
        }
Ejemplo n.º 4
0
 public static bool IsEquivalentTo(this MultiplyOutput message, MultiplyOutput otherMessage)
 {
     if (message.ResultNumber != otherMessage.ResultNumber || message.ResultString != otherMessage.ResultString)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 5
0
        private bool IsTestProtoParamResultMessageCorrect(RpcMessage message)
        {
            if (message == null || message.Id != testParamCallMessage.Id || message.ResultMessage == null)
            {
                return(false);
            }
            if (message.ResultMessage.IsFailed || message.ResultMessage.CallResult == null)
            {
                return(false);
            }

            var            memStream = new MemoryStream(message.ResultMessage.CallResult.ProtoParam);
            MultiplyOutput output    = ProtoBuf.Serializer.Deserialize <MultiplyOutput>(memStream);

            if (output.ResultNumber != 42 || output.ResultString != "Answer is 42")
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 6
0
 public void CallResultTypeFailedTest()
 {
     dynamic        serviceProxy = new DynamicProxy(client.Object, "TestServiceName");
     MultiplyOutput result       = serviceProxy.TestMethod(10, "Hello", 1.0f);
 }
Ejemplo n.º 7
0
 public static bool IsEquivalentTo(this MultiplyOutput message, MultiplyOutput otherMessage)
 {
     if (message.ResultNumber != otherMessage.ResultNumber || message.ResultString != otherMessage.ResultString)
         return false;
     return true;
 }
Ejemplo n.º 8
0
        public void ParameterProtoTest()
        {
            MultiplyInput input = new MultiplyInput();
            input.FirstNumber = 6;
            input.SecondNumber = 7;
            input.Prefix = "the prefix";
            var memInputStream = new MemoryStream();
            ProtoBuf.Serializer.Serialize(memInputStream, input);

            MultiplyOutput output = new MultiplyOutput();
            output.ResultNumber = 42;
            output.ResultString = "the result";
            var memOutputStream = new MemoryStream();
            ProtoBuf.Serializer.Serialize(memOutputStream, output);

            resultMessage.CallResult.ProtoParam = memOutputStream.ToArray();
            MultiplyOutput x = service.Multiply(input);

            Assert.That(x.ResultNumber, Is.EqualTo(42));
            Assert.That(x.ResultString, Is.EqualTo("the result"));
            client.Verify(c => c.Call("ISampleService", "Multiply", It.Is<RpcMessage.Parameter[]>(
                p => p.Length == 1 && p[0].ProtoParam.SequenceEqual(memInputStream.ToArray())), null, null));
        }