Esempio n. 1
0
        public void MixedParameterTypes()
        {
            var handler = factory.CreateMethodHandler(globalServiceImplementationInfo, new ServicePath("MyService", "MixedParameterTypes"));

            var data = new byte[8];

            fixed(byte *pData = data)
            {
                *(int *)pData        = 123;
                *(bool *)(pData + 4) = false;
            }

            var expectedData = new byte[14];

            fixed(byte *pData = expectedData)
            {
                *(bool *)pData         = true;
                *(ushort *)(pData + 4) = 246;
                *(double *)(pData + 6) = 123.456;
            }

            bool   dummyBool = false;
            ushort dummyUshort;

            service.MixedParameterTypes(0, ref dummyBool, out dummyUshort).ReturnsForAnyArgs(x =>
            {
                x[1] = true;
                x[2] = (ushort)((int)x[0] * 2);
                return(123.456);
            });

            var result = handler(service, data);

            Assert.That(result, Is.EquivalentTo(expectedData));
        }
        public void MixedParameterTypes()
        {
            var handler = CreateClass("MyService", "MixedParameterTypes")(null);

            var data = new byte[8];

            fixed(byte *pData = data)
            {
                *(int *)pData        = 123;
                *(bool *)(pData + 4) = false;
            }

            var expectedData = new byte[14];

            fixed(byte *pData = expectedData)
            {
                *(bool *)pData         = true;
                *(ushort *)(pData + 4) = 246;
                *(double *)(pData + 6) = 123.456;
            }

            bool   dummyBool = false;
            ushort dummyUshort;

            service.MixedParameterTypes(0, ref dummyBool, out dummyUshort).ReturnsForAnyArgs(x =>
            {
                x[1] = true;
                x[2] = (ushort)((int)x[0] * 2);
                return(123.456);
            });

            var result = handler.Handle(service, data, 0).Result;

            Assert.That(result, Is.EquivalentTo(expectedData));
        }