title: Create mocks with auto-filled properties with Moq?
body: <p>I have an object (like the HttpContext or other ones) that I would like to mock. Sometimes, there are some unit tests where I'm forced to mock a hefty amount of dependencies, and set their dependencies and values appropriately.</p>
  
  <p>Below there's some sample code to mock the httpcontext and another class:</p>
  
  <pre><code>    public static HttpContextBase FakeHttpContext()
      {
          var context = new Mock&lt;HttpContextBase&gt;();
          var files = new Mock&lt;HttpFileCollectionBase&gt;();
          var request = new Mock&lt;HttpRequestBase&gt;();
          var response = new Mock&lt;HttpResponseBase&gt;();
          var session = new Mock&lt;HttpSessionStateBase&gt;();
          var server = new Mock&lt;HttpServerUtilityBase&gt;();
          var user = new Mock&lt;IPrincipal&gt;();
          var identity = new Mock&lt;IIdentity&gt;();
          request.Setup(req =&gt; req.ApplicationPath).Returns("~/");
          request.Setup(req =&gt; req.AppRelativeCurrentExecutionFilePath).Returns("~/");
          request.Setup(req =&gt; req.PathInfo).Returns(string.Empty);
          request.Setup(req =&gt; req.Form).Returns(new NameValueCollection());
          request.Setup(req =&gt; req.QueryString).Returns(new NameValueCollection());
          request.Setup(req =&gt; req.Files).Returns(files.Object);
          response.Setup(res =&gt; res.ApplyAppPathModifier(MoqIt.IsAny&lt;string&gt;())).
              Returns((string virtualPath) =&gt; virtualPath);
          user.Setup(usr =&gt; usr.Identity).Returns(identity.Object);
          identity.SetupGet(ident =&gt; ident.IsAuthenticated).Returns(true);
  
          context.Setup(ctx =&gt; ctx.Request).Returns(request.Object);
          context.Setup(ctx =&gt; ctx.Response).Returns(response.Object);
          context.Setup(ctx =&gt; ctx.Session).Returns(session.Object);
          context.Setup(ctx =&gt; ctx.Server).Returns(server.Object);
          context.Setup(ctx =&gt; ctx.User).Returns(user.Object);
  
          return context.Object;
  </code></pre>
  
  <h2>        }</h2>
  
  <pre><code>        registrationView = new Mock&lt;IRegistrationView&gt;();
          registrationView.SetupGet(v =&gt; v.Address).Returns("Calle test");
          registrationView.SetupGet(v =&gt; v.EmailAddress).Returns("test@test.com");
          registrationView.SetupGet(v =&gt; v.Password).Returns("testpass");
          registrationView.SetupGet(v =&gt; v.FirstName).Returns("Name");
          registrationView.SetupGet(v =&gt; v.LastName).Returns("Surname");
          registrationView.SetupGet(v =&gt; v.DaytimePhoneNumber).Returns("666666666");
          registrationView.SetupGet(v =&gt; v.WholeSalers).Returns(new List&lt;UserWholesaler&gt;() { 
              new UserWholesaler(true) { CollaborationCode = "1234", Region = "TestReg", WholesalerCode = "10", WholesalerName = "TestWS", RegionName = "RegTest" } });
  </code></pre>
  
  <p>I wonder: is there any library that, with simply a call like "registrationView = new MockWithFilledProperties();", would allow me to create a Mock with properties filled with default values? If so, which one?</p>
  
  <p>Thank you and kind regards.</p>