Beispiel #1
0
        public void Get_Case1()
        {
            // arrange
            var method = IL.NewMethod()
                .WithParameter(typeof(Foo), "foo")
                .Returns(typeof(string))
                .Ldarg("foo")
                .CallGet<Foo>("Prop")
                .Ret();

            var foo = new Foo();

            // act
            method.Invoke(foo);

            // assert
            foo.PropGetCount.Should().Be(1);
        }
Beispiel #2
0
        public void Set_Case1()
        {
            // arrange
            var method = IL.NewMethod()
                .WithParameter(typeof(Foo), "foo")
                .Returns(typeof(void))
                .Ldarg("foo")
                .Ldstr("Hello, World!")
                .CallSet<Foo>("Prop")
                .Ret();

            var foo = new Foo();

            // act
            method.Invoke(foo);

            // assert
            foo.PropSetCount.Should().Be(1);
            foo.Prop.Should().Be("Hello, World!");
        }