Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bug using Mock.Of on objects with virtual properties. #14

Closed
Haacked opened this Issue · 5 comments

3 participants

@Haacked

The pull request #9 attempts to fix this, but there are still a few cases it doesn't work. Append the following code at the end of
QueryableMocksFixture and you'll see the tests fail.

    public class Foo
    {
        protected Foo()
        {
        }

        public virtual string Value { get; private set;}
    }

    public class FooFixture
    {
        [Fact]
        public void Test()
        {
            var remote = Mock.Of<Foo>(rt => rt.Value == "foo");
            Assert.Equal("foo", remote.Value);
        }
    }

    public interface IBar
    {
        Foo Foo { get; set; }
    }

    public class BarFixture
    {
        [Fact]
        public void Test()
        {
            var remote = Mock.Of<IBar>(rt => rt.Foo.Value == "foo");
            Assert.Equal("foo", remote.Foo.Value);
        }
    }
@Haacked Haacked referenced this issue
Merged

Fix Issue #328 #9

@Haacked

@yorah any chance you'll look at this? This bug makes the refactoring you did for us on LibGit2 useless to us. :(

@yorah

@Haacked yep, I'll look into this in the coming days. In the meantime, did you try using SetupGet to walk around this bug?

@Haacked

@yorah The problem is I have a ton of code using Mock.Of. I don't want to rewrite it all, then rewrite it again.

@nulltoken

@yorah Thanks for having taken care of this! :heart:

@Haacked Haacked closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.