RajOpteamix / moq

Automatically exported from code.google.com/p/moq
Other
0 stars 0 forks source link

Unable to verify anonymous types from different assembly #337

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a project with the following in it:

    public class Class1
    {
        private ITest _Class2;
        public Class1(ITest class2)
        {
            _Class2 = class2;
        }

        public void DoSomething()
        {
            var skus = "000456";
            var favId = 123;
            _Class2.ExecuteNonQuery("fav_AddFavorites", new { fid = favId, inputStr = skus });
        }
    }

    public interface ITest
    {
        int ExecuteNonQuery(string query, object param = null);
    }
2. Create a second project that references the first project and has the 
following test:

    [TestFixture]
    public class MyClass
    {
        [Test]
        public void ExecuteNonQueryTest()
        {
            var repository = new Mock<ITest>();

            Class1 target = new Class1(repository.Object);
            target.DoSomething();
            repository.Verify(x => x.ExecuteNonQuery("fav_AddFavorites", It.Is<object>(o => o.Equals(new { fid = 123, inputStr = "000456" }))), Times.Once());
        }
    }
3.

What is the expected output? What do you see instead?
I would expect the test to pass, but it does not. If the test and the code are 
in the same project the test passes without a problem.

What version of the product are you using? On what operating system?

I am running Moq 4.0.20926 with NUnit 2.0.50727 in a .Net 4.0 application

Please provide any additional information below.

Original issue reported on code.google.com by lizd...@nbty.com on 29 Mar 2012 at 3:23