{"action":"created","issue":{"url":"https://api.github.com/repos/Moq/moq4/issues/191","labels_url":"https://api.github.com/repos/Moq/moq4/issues/191/labels{/name}","comments_url":"https://api.github.com/repos/Moq/moq4/issues/191/comments","events_url":"https://api.github.com/repos/Moq/moq4/issues/191/events","html_url":"https://github.com/Moq/moq4/issues/191","id":95294668,"number":191,"title":"Upgrade from 4.2.1409.1722 to 4.2.1507.0118 changed VerifyAll behavior","user":{"login":"cherokeejamessmith","id":7434648,"avatar_url":"https://avatars.githubusercontent.com/u/7434648?v=3","gravatar_id":"","url":"https://api.github.com/users/cherokeejamessmith","html_url":"https://github.com/cherokeejamessmith","followers_url":"https://api.github.com/users/cherokeejamessmith/followers","following_url":"https://api.github.com/users/cherokeejamessmith/following{/other_user}","gists_url":"https://api.github.com/users/cherokeejamessmith/gists{/gist_id}","starred_url":"https://api.github.com/users/cherokeejamessmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cherokeejamessmith/subscriptions","organizations_url":"https://api.github.com/users/cherokeejamessmith/orgs","repos_url":"https://api.github.com/users/cherokeejamessmith/repos","events_url":"https://api.github.com/users/cherokeejamessmith/events{/privacy}","received_events_url":"https://api.github.com/users/cherokeejamessmith/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-15T21:27:58Z","updated_at":"2015-07-16T13:15:37Z","closed_at":null,"body":"VerifyAll() fails for setups that weren't created following the upgrade. In particular, any mock made from an interface containing a get-only property fails on not satisfying a set on that property. All failing tests **do not have setups** for the methods/properties being reported as not matched.\r\n\r\n```\r\nMoq.MockVerificationException: Moq.MockVerificationException: The following setups were not matched:\r\n\r\nIDbContext m => m.Database\r\n```\r\n\r\nwhere IDbContext is defined:\r\n```\r\n\tpublic interface IDbContext : IDisposable\r\n\t{\r\n\t\tDatabase Database { get; }\r\n\t\t// Other methods...\r\n\t}\r\n```\r\nAdditionally, there seems to be a recursive traversal of properties that are somehow getting automatically wired up as a setup. Here, IConfigurationManager defined as:\r\n```\r\n\tpublic interface IConfigurationManager\r\n\t{\r\n\t\tNameValueCollection AppSettings { get; }\r\n\t\t// Other methods...\r\n\t}\r\n```\r\nAny tests using a mock of type IConfigurationManager produces the following failure message:\r\n```\r\nMoq.MockVerificationException: Moq.MockVerificationException: The following setups were not matched:\r\n\r\nNameValueCollection m => m.AllKeys\r\n\r\nNameValueCollection m => m.Count\r\n\r\nNameValueCollection m => m.Keys\r\n\r\nNameValueCollection m => m.Count\r\n\r\nNameValueCollection m => m.SyncRoot\r\n\r\nNameValueCollection m => m.IsSynchronized\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Moq/moq4/issues/comments/121952637","html_url":"https://github.com/Moq/moq4/issues/191#issuecomment-121952637","issue_url":"https://api.github.com/repos/Moq/moq4/issues/191","id":121952637,"user":{"login":"cherokeejamessmith","id":7434648,"avatar_url":"https://avatars.githubusercontent.com/u/7434648?v=3","gravatar_id":"","url":"https://api.github.com/users/cherokeejamessmith","html_url":"https://github.com/cherokeejamessmith","followers_url":"https://api.github.com/users/cherokeejamessmith/followers","following_url":"https://api.github.com/users/cherokeejamessmith/following{/other_user}","gists_url":"https://api.github.com/users/cherokeejamessmith/gists{/gist_id}","starred_url":"https://api.github.com/users/cherokeejamessmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cherokeejamessmith/subscriptions","organizations_url":"https://api.github.com/users/cherokeejamessmith/orgs","repos_url":"https://api.github.com/users/cherokeejamessmith/repos","events_url":"https://api.github.com/users/cherokeejamessmith/events{/privacy}","received_events_url":"https://api.github.com/users/cherokeejamessmith/received_events","type":"User","site_admin":false},"created_at":"2015-07-16T13:15:37Z","updated_at":"2015-07-16T13:15:37Z","body":"Hey @kzu, thanks for the reply. I went through the process of creating a stand alone solution to reproduce the problem and discovered an additional detail. The problem manifests when chaining into a subdependency on setup where that subdependency has a get-only property exposed on the interface. Here's the repo code:\r\n```\r\nusing Microsoft.VisualStudio.TestTools.UnitTesting;\r\nusing Moq;\r\n\r\nnamespace MoqTest\r\n{\r\n\t[TestClass]\r\n\tpublic class Tests\r\n\t{\r\n\t\t[TestMethod]\r\n\t\tpublic void DoSomething_NormalConditions_CallsDependency()\r\n\t\t{\r\n\t\t\tvar mockDependency = new Mock<IDependency>();\r\n\t\t\tvar service = new TestService( mockDependency.Object );\r\n\t\t\tmockDependency\r\n\t\t\t\t.Setup( m => m.CreateDependency().Foo() );\r\n\r\n\t\t\tservice.DoSomething();\r\n\r\n\t\t\tmockDependency.VerifyAll();\r\n\t\t}\r\n\t}\r\n\r\n\tpublic class Payload\r\n\t{\r\n\t}\r\n\r\n\tpublic interface IDependency\r\n\t{\r\n\t\tISubDependency CreateDependency();\r\n\t}\r\n\r\n\tpublic interface ISubDependency\r\n\t{\r\n\t\tvoid Foo();\r\n\t\tPayload Payload { get; }\r\n\t}\r\n\r\n\tpublic class TestService\r\n\t{\r\n\t\tprivate readonly IDependency _dependency;\r\n\r\n\t\tpublic TestService( IDependency dependency )\r\n\t\t{\r\n\t\t\t_dependency = dependency;\r\n\t\t}\r\n\r\n\t\tpublic void DoSomething()\r\n\t\t{\r\n\t\t\t_dependency.CreateDependency().Foo();\r\n\t\t}\r\n\t}\r\n}\r\n```\r\n\r\nHere is the Test output:\r\n```\r\nTest method MoqTest.Tests.DoSomething_NormalConditions_CallsDependency threw exception: \r\n\r\nMoq.MockVerificationException: The following setups were not matched:\r\n\r\nISubDependency m => m.Payload\r\n\r\n\r\n    at Moq.Mock.VerifyAll()\r\n   at MoqTest.Tests.DoSomething_NormalConditions_CallsDependency() in TestClass.cs: line 19\r\n\r\n\r\n```\r\n\r\nThis was a new solution in Visual Studio 2013 Update 4 targeting the .Net 4.5.2 framework. Here are the references used by the project:\r\n\r\n```\r\n    <Reference Include=\"Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\" />\r\n    <Reference Include=\"Moq, Version=4.2.1507.118, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL\">\r\n      <HintPath>..\\packages\\Moq.4.2.1507.0118\\lib\\net40\\Moq.dll</HintPath>\r\n      <Private>True</Private>\r\n    </Reference>\r\n    <Reference Include=\"System\" />\r\n    <Reference Include=\"System.Core\" />\r\n    <Reference Include=\"System.Xml.Linq\" />\r\n    <Reference Include=\"System.Data.DataSetExtensions\" />\r\n    <Reference Include=\"Microsoft.CSharp\" />\r\n    <Reference Include=\"System.Data\" />\r\n    <Reference Include=\"System.Xml\" />\r\n```"}}