Ejemplo n.º 1
0
        public void Ref()
        {
            var handler = factory.CreateMethodHandler(globalServiceImplementationInfo, new ServicePath("MyService", "ModifyByRef"));

            var data = new byte[8];

            fixed(byte *pData = data)
            {
                *(double *)pData = 12.34;
            }

            var expectedData = new byte[8];

            fixed(byte *pData = expectedData)
            {
                *(double *)pData = 24.68;
            }

            double dummy = 0;

            service.WhenForAnyArgs(x => x.ModifyByRef(ref dummy)).Do(x => { x[0] = (double)x[0] * 2; });

            var result = handler(service, data);

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

            var data = new byte[8];

            fixed(byte *pData = data)
            {
                *(double *)pData = 12.34;
            }

            var expectedData = new byte[8];

            fixed(byte *pData = expectedData)
            {
                *(double *)pData = 24.68;
            }

            double dummy = 0;

            service.WhenForAnyArgs(x => x.ModifyByRef(ref dummy)).Do(x => { x[0] = (double)x[0] * 2; });

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

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