Ejemplo n.º 1
0
        public void Prig_should_fake_static_property_set()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                PFoo.StaticConstructor().Body = () => { };

                var fooPropSetMock = new Mock <IndirectionAction <int> >(MockBehavior.Strict);
                fooPropSetMock.Setup(_ => _(10));
                PFoo.FooPropSetInt32().Body = fooPropSetMock.Object;


                // Act, Assert
                Foo.FooProp = 10;
            }
        }
Ejemplo n.º 2
0
        public void Prig_should_arrange_static_function()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                PFoo.StaticConstructor().Body = () => { };
                PFoo.FooPropGet().Body        = () => 0;


                // Act
                var actual = Foo.FooProp;


                // Assert
                Assert.AreEqual(0, actual);
            }
        }
Ejemplo n.º 3
0
        public void Prig_should_fake_static_property_get()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                PFoo.StaticConstructor().Body = () => { };

                var called             = false;
                PFoo.FooPropGet().Body = () => { called = true; return(1); };


                // Act
                var actual = Foo.FooProp;


                // Assert
                Assert.AreEqual(1, actual);
                Assert.IsTrue(called);
            }
        }
Ejemplo n.º 4
0
        public void Prig_should_throw_when_not_arranged()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                PFoo.StaticConstructor().Body = () => { };

                var executeMock = new Mock <IndirectionFunc <int, int> >(MockBehavior.Strict);
                executeMock.Setup(_ => _(10)).Returns(10);
                PFoo.ExecuteInt32().Body = executeMock.Object;

                var submitMock     = new Mock <IndirectionAction>(MockBehavior.Strict);
                PFoo.Submit().Body = submitMock.Object;


                // Act, Assert
                Assert.AreEqual(10, Foo.Execute(10));
                Assert.Throws <MockException>(() => Foo.Submit());
            }
        }