public void InitTest()
 {
     // We can't use ClassInitialize in a base class
     if (app == null)
     {
         app = new MvcWebApp();
         lc = AssemblyStartup.LoadedConfig;
         ITH = new IntegrationTestHelpers(app, lc);
     }
     Console.WriteLine("TestInit");
     ITH.LoginAndResetDatabase();
 }
        public static void AssemblyInit(TestContext tc)
        {
            // so we can use the resources in our test even if your language is not en-US
            Resources.Culture = new System.Globalization.CultureInfo("en-US");

            LoadedConfig = LoadConfiguration();

            var config = new SpecsForMvcConfig();
            //SpecsFor.Mvc can spin up an instance of IIS Express to host your app
            //while the specs are executing.
            config.UseIISExpress()
                //To do that, it needs to know the name of the project to test...
                .With(Project.Named("Bonobo.Git.Server"))
                .UsePort(20000)
                //And optionally, it can apply Web.config transformations if you want
                //it to.
                .ApplyWebConfigTransformForConfig("Test");

            //In order to leverage the strongly-typed helpers in SpecsFor.Mvc,
            //you need to tell it about your routes.  Here we are just calling
            //the infrastructure class from our MVC app that builds the RouteTable.
            config.BuildRoutesUsing(r => Bonobo.Git.Server.App_Start.RouteConfig.RegisterRoutes(r));
            //SpecsFor.Mvc can use either Internet Explorer or Firefox.  Support
            //for Chrome is planned for a future release.
            config.UseBrowser(BrowserDriver.InternetExplorer);

            // We cannot use the authenticate before each step helper
            // because it is only executed once per class.
            // So if class A test1 runs, then class B test2 (this leaves us logged out)
            // then class A test2 (which assumes we are logged in). It will fail
            //config.AuthenticateBeforeEachTestUsing<AuthHandler>();

            //Does your application send E-mails?  Well, SpecsFor.Mvc can intercept
            //those while your specifications are executing, enabling you to write
            //tests against the contents of sent messages.
            //config.InterceptEmailMessagesOnPort(13565);

            // If we set a WithPublishDirectory above, then this would change
            WebApplicationDirectory = Path.Combine(Directory.GetCurrentDirectory(), "SpecsForMvc.TestSite");

            //The host takes our configuration and performs all the magic.  We
            //need to keep a reference to it so we can shut it down after all
            //the specifications have executed.
            _host = new SpecsForIntegrationHost(config);
            _host.Start();
        }
        public static void ClassInit(TestContext testContext)
        {
            // Make sure relative paths are frozen in case the app's CurrentDir changes
            // WorkingDirectory = Path.GetFullPath(WorkingDirectory);
            // GitPath = Path.GetFullPath(GitPath);
            // RepositoryDirectory = Path.Combine(WorkingDirectory, RepositoryName);

            List<string> not_found = new List<string>();

            foreach (var version in GitVersions)
            {
                var git = String.Format(GitPath, version);
                if (File.Exists(git))
                {
                    installedgits.Add(new GitInstance { GitExe =  git, Resources =  new MsysgitResources(version) });
                }
                else
                {
                    not_found.Add(git);
                }
            }

            if (!installedgits.Any())
            {
                Assert.Fail(string.Format("Please ensure that you have at least one git installation in '{0}'.", string.Join("', '", not_found.Select(n => Path.GetFullPath(n)))));
            }

            lc = AssemblyStartup.LoadedConfig;

            AdminCredentials = lc.getUrlLogin("admin") + "@";
            UserCredentials = lc.getUrlLogin("user") + "@";

            Directory.CreateDirectory(WorkingDirectory);

            if (AnyCredentialHelperExists(installedgits.Last()))
            {
                /* At the moment there is no reliable way of overriding credential.helper on a global basis.
                 * See the other comments for all the other bugs found so far.
                 * Having a credential helper set makes it impossible to check in non authorized login
                 * after a login with username and password has been done. */
                Assert.Fail("Cannot have any credential.helpers configured for integration tests.");
            }

            app = new MvcWebApp();
            ITH = new IntegrationTestHelpers(app, lc);

            RepositoryUrlWithCredentials = String.Format(RepositoryUrlTemplate, AdminCredentials, ".git", RepositoryName);
            RepositoryUrlWithoutCredentials = String.Format(RepositoryUrlTemplate, String.Empty, String.Empty, RepositoryName);
            Url = string.Format(RepositoryUrlTemplate, string.Empty, string.Empty, string.Empty);
            BareUrl = Url.TrimEnd('/');
        }