{"action":"created","issue":{"url":"https://api.github.com/repos/nunit/nunit/issues/841","labels_url":"https://api.github.com/repos/nunit/nunit/issues/841/labels{/name}","comments_url":"https://api.github.com/repos/nunit/nunit/issues/841/comments","events_url":"https://api.github.com/repos/nunit/nunit/issues/841/events","html_url":"https://github.com/nunit/nunit/issues/841","id":107951004,"number":841,"title":"Moq as TestCaseSource dosen't work","user":{"login":"meriturva","id":5664195,"avatar_url":"https://avatars.githubusercontent.com/u/5664195?v=3","gravatar_id":"","url":"https://api.github.com/users/meriturva","html_url":"https://github.com/meriturva","followers_url":"https://api.github.com/users/meriturva/followers","following_url":"https://api.github.com/users/meriturva/following{/other_user}","gists_url":"https://api.github.com/users/meriturva/gists{/gist_id}","starred_url":"https://api.github.com/users/meriturva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meriturva/subscriptions","organizations_url":"https://api.github.com/users/meriturva/orgs","repos_url":"https://api.github.com/users/meriturva/repos","events_url":"https://api.github.com/users/meriturva/events{/privacy}","received_events_url":"https://api.github.com/users/meriturva/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nunit/nunit/labels/status:confirm","name":"status:confirm","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/nunit/nunit/milestones/14","html_url":"https://github.com/nunit/nunit/milestones/3.0RC","labels_url":"https://api.github.com/repos/nunit/nunit/milestones/14/labels","id":1173766,"number":14,"title":"3.0RC","description":"","creator":{"login":"CharliePoole","id":2678661,"avatar_url":"https://avatars.githubusercontent.com/u/2678661?v=3","gravatar_id":"","url":"https://api.github.com/users/CharliePoole","html_url":"https://github.com/CharliePoole","followers_url":"https://api.github.com/users/CharliePoole/followers","following_url":"https://api.github.com/users/CharliePoole/following{/other_user}","gists_url":"https://api.github.com/users/CharliePoole/gists{/gist_id}","starred_url":"https://api.github.com/users/CharliePoole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CharliePoole/subscriptions","organizations_url":"https://api.github.com/users/CharliePoole/orgs","repos_url":"https://api.github.com/users/CharliePoole/repos","events_url":"https://api.github.com/users/CharliePoole/events{/privacy}","received_events_url":"https://api.github.com/users/CharliePoole/received_events","type":"User","site_admin":false},"open_issues":14,"closed_issues":29,"state":"open","created_at":"2015-06-21T02:40:59Z","updated_at":"2015-10-06T07:43:27Z","due_on":"2015-10-10T07:00:00Z","closed_at":null},"comments":12,"created_at":"2015-09-23T15:53:33Z","updated_at":"2015-10-06T13:22:54Z","closed_at":null,"body":"Hi to all,\r\nwe use TestCaseSource with Mock instances and we found that the test is not called.\r\nWe use the NUnit 3 beta 4 version with Visual Studio 2015 Community Edition.\r\nThis is just a sample code to reproduce the problem:\r\n\r\n```C#\r\n    public class Value\r\n    {\r\n        public double RowVale { get; set; }\r\n    }\r\n\r\n    [TestFixture]\r\n    public class TestTest\r\n    {\r\n        private static Value[] Values = new Test.Value[2];\r\n        \r\n        static TestTest()\r\n        {\r\n            Values[0] = new Value()\r\n            {\r\n                RowVale = 10\r\n            };\r\n\r\n            var mockValue = new Mock<Value>();\r\n            Values[1] = mockValue.Object;\r\n        }\r\n\r\n        [Test, TestCaseSource(\"Values\")]\r\n        public void TestTestCaseSourceWithMoq(Value value)\r\n        {\r\n           \r\n        }\r\n\r\n    }\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/nunit/nunit/issues/comments/145854639","html_url":"https://github.com/nunit/nunit/issues/841#issuecomment-145854639","issue_url":"https://api.github.com/repos/nunit/nunit/issues/841","id":145854639,"user":{"login":"x789","id":14997061,"avatar_url":"https://avatars.githubusercontent.com/u/14997061?v=3","gravatar_id":"","url":"https://api.github.com/users/x789","html_url":"https://github.com/x789","followers_url":"https://api.github.com/users/x789/followers","following_url":"https://api.github.com/users/x789/following{/other_user}","gists_url":"https://api.github.com/users/x789/gists{/gist_id}","starred_url":"https://api.github.com/users/x789/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/x789/subscriptions","organizations_url":"https://api.github.com/users/x789/orgs","repos_url":"https://api.github.com/users/x789/repos","events_url":"https://api.github.com/users/x789/events{/privacy}","received_events_url":"https://api.github.com/users/x789/received_events","type":"User","site_admin":false},"created_at":"2015-10-06T13:22:54Z","updated_at":"2015-10-06T13:22:54Z","body":"I faced the same behaviour today using the 2.0 version of the NUnit test adapter for VS2013. But even if the adapter would support a mock created with Moq the name of the test would change each time it is executed.\r\n\r\nTo work around this behaviour I use NUnit's TestCaseData class to provide the test-data and the name of the test-case. This name does not change between initialization and execution so the NUnit test adapter executs my tests flawlessly. However it has the draw-back that the array used as TestCaseSource can be used only for one test-method (to avoid name collisions).\r\n\r\nMy code is similar to the following:\r\n\r\n    [TestCaseFixture]\r\n    public class MyTest\r\n    {\r\n      private static TestCaseData[] testData = new TestCaseData[] { \r\n                                                                    new TestCaseData(null).SetName(\"Test01(null)\"),\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t    new TestCaseData(new Mock<IMyInterface>().Object).SetName(\"Test01(with mock)\") };\r\n    \r\n      [Test, TestCaseSource(\"testData\")]\r\n      public void Test01(IMyInterface param)\r\n      {\r\n        // Test logic\r\n      }\r\n\t}"}}