Esempio n. 1
0
        public void ExchangeT_should_be_callable_indirectly()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                PInterlocked.ExchangeOfTTRefT <MyData>().Body = (ref MyData location1, MyData value) =>
                {
                    location1 = value;
                    return(new MyData(42));
                };

                // Act
                var data1  = new MyData(100);
                var data2  = new MyData(200);
                var actual = Interlocked.Exchange(ref data1, data2);

                // Assert
                Assert.AreEqual(200, data1.Value);
                Assert.AreEqual(42, actual.Value);
            }
        }
        public void AutoConfiguredMoqPrigCustomization_should_not_mock_generic_method_because_we_cannot_determine_the_generic_argument()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var ms      = new MockStorage(MockBehavior.Default);
                var fixture = new Fixture().Customize(new AutoConfiguredMoqPrigCustomization(ms));

                PInterlocked.ExchangeOfTTRefT <Version>().Body = (ref Version location1, Version value) => new Version(1, 2, 3);
                fixture.Create <PInterlocked>();


                // Act
                var location = new Version(4, 5, 6);
                var result   = Interlocked.Exchange(ref location, new Version(7, 8, 9));


                // Assert
                Assert.AreEqual(new Version(4, 5, 6), location);
                Assert.AreEqual(new Version(1, 2, 3), result);
            }
        }