Exemple #1
0
        public void GetMemory_should_be_callable_indirectly_against_only_specified_instance()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var smProxy = new PProxyULSharedMemory();
                smProxy.GetMemoryInt32ByteArrayRef().Body = (ULSharedMemory @this, int size, out byte[] buf) =>
                {
                    buf = new byte[42];
                    for (int i = 0; i < buf.Length; i++)
                    {
                        buf[i] = 42;
                    }
                    return(true);
                };
                var sm_sut = (ULSharedMemory)smProxy;


                using (var sm = new ULSharedMemory())
                {
                    // Act
                    var size = 1024;

                    var buf_sut    = default(byte[]);
                    var actual_sut = sm_sut.GetMemory(size, out buf_sut);

                    var buf    = default(byte[]);
                    var actual = sm.GetMemory(size, out buf);

                    // Assert
                    Assert.IsTrue(actual_sut);
                    Assert.AreEqual(42, buf_sut.Length);
                    Assert.AreEqual((byte)42, buf_sut[0]);
                    Assert.AreEqual((byte)42, buf_sut[buf_sut.Length - 1]);

                    Assert.AreNotEqual(buf.Length, buf_sut.Length); // constant value is just Length :)
                }
            }
        }
Exemple #2
0
        public void GetMemory_should_be_callable_indirectly_against_only_specified_instance()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var smProxy = new PProxyULSharedMemory();
                smProxy.GetMemoryInt32ByteArrayRef().Body = (ULSharedMemory @this, int size, out byte[] buf) =>
                {
                    buf = new byte[42];
                    for (int i = 0; i < buf.Length; i++)
                        buf[i] = 42;
                    return true;
                };
                var sm_sut = (ULSharedMemory)smProxy;


                using (var sm = new ULSharedMemory())
                {
                    // Act
                    var size = 1024;

                    var buf_sut = default(byte[]);
                    var actual_sut = sm_sut.GetMemory(size, out buf_sut);

                    var buf = default(byte[]);
                    var actual = sm.GetMemory(size, out buf);

                    // Assert
                    Assert.IsTrue(actual_sut);
                    Assert.AreEqual(42, buf_sut.Length);
                    Assert.AreEqual((byte)42, buf_sut[0]);
                    Assert.AreEqual((byte)42, buf_sut[buf_sut.Length - 1]);

                    Assert.AreNotEqual(buf.Length, buf_sut.Length); // constant value is just Length :)
                }
            }
        }