{"id":5856,"date":"2014-04-07T09:40:13","date_gmt":"2014-04-07T09:40:13","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/07\/how-to-create-and-pass-a-lazyttmetadata-for-unit-testing-collection-of-common-programming-errors\/"},"modified":"2014-04-07T09:40:13","modified_gmt":"2014-04-07T09:40:13","slug":"how-to-create-and-pass-a-lazyttmetadata-for-unit-testing-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/07\/how-to-create-and-pass-a-lazyttmetadata-for-unit-testing-collection-of-common-programming-errors\/","title":{"rendered":"How to create and pass a lazy&lt;T,Tmetadata&gt; for unit testing?-Collection of common programming errors"},"content":{"rendered":"<p>Hello all,<\/p>\n<p>So i decided to create a repository for my MEF project, this would allow me to swap out the source for\u00a0my given situation (runtime, testing, etc&#8230;) However, I&#8217;ve noticed and I understand that most use lazy loading for the MEF importmany plugin property\/field. My issue is attempting to build a repository that returns test plugin classes, but of course i&#8217;m having problems instantiating the lazy property in the test repository. Thoughts?<\/p>\n<pre>public List GetAllPlugins()\n        {\n            _testPluginList.Add(new Lazy\n                (\n                    () =&gt;\n                    {\n                        IPluginContract testPluginOne = new TestPluginContract();\n                        return testPluginOne;\n                    }\n               )\n            );\n            _testPluginList.Add(new Lazy\n                (\n                    () =&gt;\n                    {\n                        IPluginContract testPluginTwo = new TestPluginContract();\n                        return testPluginTwo;\n                    }\n                )\n            );\n            return _testPluginList;\n        }<\/pre>\n<p>Thoughts anyone?<\/p>\n<p>I get the following error when attempting to build:<\/p>\n<p>&#8220;Cannot convert anonymous method to type &#8216;System.Collections.Generic.IDictionary&#8217; because it is not a delegate type&#8221; ;\u00a0that is on both\u00a0list.Add methods.\u00a0<\/p>\n<p>May the Force be with you young Jedi&#8230;<\/p>\n<p><code>Console.WriteLine(\"-Warren\");<\/code><\/p>\n<p>Please Help your Helper(s) =)<\/p>\n<p>\nIf you find someone&#8217;s post helpful please click the green &#8220;up arrow&#8221; to the left and vote!<br \/>\nDid someone&#8217;s post Answer your question? Mark it as the Answer!<br \/>\nIt&#8217;s Greatly Appreciated =)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello all, So i decided to create a repository for my MEF project, this would allow me to swap out the source for\u00a0my given situation (runtime, testing, etc&#8230;) However, I&#8217;ve noticed and I understand that most use lazy loading for the MEF importmany plugin property\/field. My issue is attempting to build a repository that returns [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5856","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5856"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5856\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}