public void Setup()
        {
            _existingDbPerson = IntegrationTestHelpers.CreateExistingPerson(DatabaseContext);
            _mashReferral     = IntegrationTestHelpers.SaveMashReferralToDatabase(DatabaseContext, "CONTACT");

            _unlinkedResident = IntegrationTestHelpers.CreateMashResident(DatabaseContext, _mashReferral, _existingDbPerson);
        }
 public void InitTest()
 {
     // We can't use ClassInitialize in a base class
     if (app == null)
     {
         app = new MvcWebApp();
         ITH = new IntegrationTestHelpers(app);
     }
     Console.WriteLine("TestInit");
     ITH.LoginAndResetDatabase();
 }
 public void InitTest()
 {
     // We can't use ClassInitialize in a base class
     if (app == null)
     {
         app = new MvcWebApp();
         ITH = new IntegrationTestHelpers(app);
     }
     Console.WriteLine("TestInit");
     ITH.LoginAndResetDatabase();
 }
        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('/');
        }
        public void EnsureCookiePersistBetweenBrowserRestart()
        {
            app.NavigateTo <HomeController>(c => c.LogOff()); // in case the cookie is set
            app.NavigateTo <RepositoryController>(c => c.Index(null, null));
            app.Browser.Manage().Cookies.DeleteAllCookies();
            Thread.Sleep(TimeSpan.FromSeconds(5)); // give it some time to delete the cookies

            app.NavigateTo <AccountController>(c => c.Detail(new Guid("7479fc09-2c0b-4e93-a2cf-5e4bbf6bab4f")));
            app.UrlShouldMapTo <HomeController>(c => c.LogOn("/Account/Detail/7479fc09-2c0b-4e93-a2cf-5e4bbf6bab4f"));

            var form     = app.FindFormFor <LogOnModel>();
            var chkField = form.Field(f => f.Username).SetValueTo("admin")
                           .Field(f => f.Password).SetValueTo("admin")
                           .Field(f => f.RememberMe).Field;

            ITH.SetCheckbox(chkField, true);
            form.Submit();
            app.UrlShouldMapTo <AccountController>(c => c.Detail(new Guid("7479fc09-2c0b-4e93-a2cf-5e4bbf6bab4f")));

            MvcWebApp.Driver.Shutdown();
            app = new MvcWebApp();
            ITH = new IntegrationTestHelpers(app, lc);
            app.NavigateTo <AccountController>(c => c.Detail(new Guid("7479fc09-2c0b-4e93-a2cf-5e4bbf6bab4f")));
            app.UrlShouldMapTo <AccountController>(c => c.Detail(new Guid("7479fc09-2c0b-4e93-a2cf-5e4bbf6bab4f")));
            // ok we re logged in with success.

            // Now let's make sure we can unset remember me
            app.NavigateTo <HomeController>(c => c.LogOff());
            app.NavigateTo <HomeController>(c => c.LogOn(""));
            form     = app.FindFormFor <LogOnModel>();
            chkField = form.Field(f => f.Username).SetValueTo("admin")
                       .Field(f => f.Password).SetValueTo("admin")
                       .Field(f => f.RememberMe).Field;
            ITH.SetCheckbox(chkField, false);
            form.Submit();

            app.UrlShouldMapTo <RepositoryController>(c => c.Index(null, null));

            MvcWebApp.Driver.Shutdown();
            app = new MvcWebApp();
            ITH = new IntegrationTestHelpers(app, lc);

            app.NavigateTo <AccountController>(c => c.Detail(new Guid("7479fc09-2c0b-4e93-a2cf-5e4bbf6bab4f")));
            app.UrlShouldMapTo <HomeController>(c => c.LogOn("/Account/Detail/7479fc09-2c0b-4e93-a2cf-5e4bbf6bab4f"));
        }
        public void EnsureCookiePersistBetweenBrowserRestart()
        {
            app.NavigateTo<HomeController>(c => c.LogOff()); // in case the cookie is set
            app.NavigateTo<RepositoryController>(c => c.Index(null, null));
            app.Browser.Manage().Cookies.DeleteAllCookies();
            Thread.Sleep(TimeSpan.FromSeconds(5)); // give it some time to delete the cookies

            app.NavigateTo<RepositoryController>(c => c.Index(null, null));
            app.UrlShouldMapTo<HomeController>(c => c.LogOn("/Repository/Index"));
            var form = app.FindFormFor<LogOnModel>();
            var chkField = form.Field(f => f.Username).SetValueTo("admin")
                .Field(f=> f.Password).SetValueTo("admin")
                .Field(f => f.RememberMe).Field;
            ITH.SetCheckbox(chkField, true);
            form.Submit();
            app.UrlShouldMapTo<RepositoryController>(c => c.Index(null, null));

            MvcWebApp.Driver.Shutdown();
            app = new MvcWebApp();

            app.NavigateTo<RepositoryController>(c => c.Index(null, null));
            app.UrlShouldMapTo<RepositoryController>(c => c.Index(null, null));
            // ok we re logged in with success.

            // Now let's make sure we can unset remember me
            app.NavigateTo<HomeController>(c => c.LogOff());
            app.NavigateTo<HomeController>(c => c.LogOn(""));
            form = app.FindFormFor<LogOnModel>();
            chkField = form.Field(f => f.Username).SetValueTo("admin")
                .Field(f=> f.Password).SetValueTo("admin")
                .Field(f => f.RememberMe).Field;
            ITH.SetCheckbox(chkField, false);
            form.Submit();

            app.UrlShouldMapTo<RepositoryController>(c => c.Index(null, null));

            MvcWebApp.Driver.Shutdown();
            app = new MvcWebApp();
            ITH = new IntegrationTestHelpers(app, lc);

            app.NavigateTo<RepositoryController>(c => c.Index(null, null));
            app.UrlShouldMapTo<HomeController>(c => c.LogOn("/Repository/Index"));
        }
        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('/');
        }
Beispiel #8
0
 public void Setup()
 {
     // Create existing referral and unrelated worker
     _existingDbReferral = IntegrationTestHelpers.SaveMashReferralToDatabase(DatabaseContext, "CONTACT");
 }
Beispiel #9
0
 public void Setup()
 {
     // Create existing referral and unrelated worker
     (_existingDbWorker, _) = IntegrationTestHelpers.SetupExistingWorker(DatabaseContext);
     _existingDbReferral    = IntegrationTestHelpers.SaveMashReferralToDatabase(DatabaseContext);
 }
 public void SetUp()
 {
     _person      = IntegrationTestHelpers.CreateExistingPerson(DatabaseContext, ageContext: "C");
     (_worker, _) = IntegrationTestHelpers.SetupExistingWorker(DatabaseContext);
 }
Beispiel #11
0
 public void SetUp()
 {
     (_caseStatuses, _person) = IntegrationTestHelpers.SavePersonWithMultipleCaseStatusesToDatabase(DatabaseContext, addClosedCaseStatuses: true);
 }