title: Using StructureMap with unit tests
body: <p>I'm using StructureMap in a web project for DI IOC. It works perfect, but I don't have a clue how to write unit tests with StructureMap.</p>
  
  <p>Should I do this in AssemblyInitialize start Configuration of StructureMap like in global.asax except for datacontext not to use live LinqToSqlDataContext but some memory data like this:</p>
  
  <pre><code> [AssemblyInitialize]
   public static void Start()
   {
          ObjectFactory.Configure(x =&gt;
                  {
                      x.For&lt;IDataContext&gt;().HttpContextScoped().Use&lt;MemoryDataContext&gt;()
                          .Ctor&lt;string&gt;("connectionString")
                          .Is(ConfigurationManager.ConnectionStrings["DEVConnection"].ConnectionString);
                      x.For&lt;IDepartamentRepository&gt;().Use&lt;DepartamentDB&gt;();
                      x.For&lt;IDevelopmentProcess&gt;().Use&lt;DevelopmentProcesses&gt;().OnCreation(c =&gt; c.User = Current.CurrentUser);
                      x.For&lt;IActivityProcess&gt;().Use&lt;ActivitiesProcess&gt;().OnCreation(c=&gt; c.User = Current.CurrentUser);
                      x.For&lt;IDevDeveloperRepository&gt;().Use&lt;DevDeveloperDB&gt;();
                      x.For&lt;IDevelopmentRepository&gt;().Use&lt;DevelopmentDB&gt;();
                      x.For&lt;IActivityRepository&gt;().Use&lt;ActivityDB&gt;();
                      x.For&lt;IActivityTypeRepository&gt;().Use&lt;ActivityTypeDB&gt;();
                      x.For&lt;IDevUserRepository&gt;().Use&lt;DevUsersDB&gt;();
                      x.For&lt;IAttachmentRepository&gt;().Use&lt;AttachmentDB&gt;();
                  }
              );
   }
  </code></pre>
  
  <p>and then use ObjectFactory.GetInstance() testing or how do I do this?</p>