Exemple #1
0
        private static void AddAppServers()
        {
            IEnumerable <InstallationEnvironment> environments = InstallationEnvironmentLogic.GetAll();

            for (int i = 1; i <= TotalNumberOfEachEntityToCreate; i++)
            {
                ApplicationServer server = new ApplicationServer();

                server.Name = "server" + i;
                server.InstallationEnvironment = environments.Where(x => x.LogicalOrder == 1).First();        // 1st env is dev
                server.Description             = "Description " + i;
                server.EnableDebugLogging      = false;

                Application app = ApplicationLogic.GetByName("app" + i);
                server.ApplicationsWithOverrideGroup.Add(new ApplicationWithOverrideVariableGroup()
                {
                    Enabled = true, Application = app
                });

                CustomVariableGroup group = CustomVariableGroupLogic.GetByName("group" + i);
                server.CustomVariableGroups.Add(group);

                ApplicationServerLogic.Save(server);
            }
        }
Exemple #2
0
        static TestHelper()
        {
            TestUtility.PossiblyAddInstallationEnvironments();
            _defaultEnv = InstallationEnvironmentLogic.GetAll().First();

            // Create some generic apps so our servers can have more than one app assigned to them.
            for (int i = 1; i <= 5; i++)
            {
                var app = CreateApp("Generic" + i);
                _genericApps.Add(app);
            }
        }
Exemple #3
0
        internal static void PossiblyAddInstallationEnvironments()
        {
            List <InstallationEnvironment> environments = InstallationEnvironmentLogic.GetAll().ToList();

            if (environments.Count > 0)
            {
                return;
            }

            AddInstallationEnvironment("Development", 1);
            AddInstallationEnvironment("QA", 2);
            AddInstallationEnvironment("Staging", 3);
            AddInstallationEnvironment("Production", 4);
        }
Exemple #4
0
        private TestEntityContainer CreateTestEntityContainer(string rootName,
                                                              Func <InstallationSummary, DateTime> forceInstallationTimeFunc,
                                                              bool forceInstallEnvironmentShouldMatch, bool freezeAllInstallations, int numberOfInstallationSummariesToCreate)
        {
            // Creates all of the entities for a particular use case and stores them in a container. This is done
            // because many of the methods in this class do this same thing.

            SetGlobalFreeze(freezeAllInstallations);

            TestHelper.CreateAndPersistEntitiesForAUseCase(rootName, numberOfInstallationSummariesToCreate);

            ApplicationServer appServer = ApplicationServerLogic.GetByName(TestHelper.GetServerName(rootName));

            // So we can check the event log and see that this test passed/failed for the right reason.
            appServer.EnableDebugLogging = _enableAppServerDebugLogging;

            // Use this app and group
            string appName = TestHelper.GetAppName(rootName);
            ApplicationWithOverrideVariableGroup appWithGroup = appServer.ApplicationsWithOverrideGroup.Where(x => x.Application.Name == appName).First();

            // Get the most recent InstallationSummary for this server.
            InstallationSummary mostRecentInstallationSummary = InstallationSummaryLogic.GetMostRecentByServerAppAndGroup(appServer, appWithGroup);

            ForceInstallation forceInstallation = new ForceInstallation();

            forceInstallation.ForceInstallationTime = forceInstallationTimeFunc.Invoke(mostRecentInstallationSummary);

            if (forceInstallEnvironmentShouldMatch)
            {
                forceInstallation.ForceInstallEnvironment = appServer.InstallationEnvironment;
            }
            else
            {
                forceInstallation.ForceInstallEnvironment =
                    InstallationEnvironmentLogic.GetAll().Where(x => x.LogicalOrder != appServer.InstallationEnvironment.LogicalOrder).First();
            }

            appWithGroup.Application.ForceInstallation = forceInstallation;

            TestEntityContainer container = new TestEntityContainer();

            container.ApplicationServer             = appServer;
            container.AppWithGroup                  = appWithGroup;
            container.ForceInstallation             = forceInstallation;
            container.MostRecentInstallationSummary = mostRecentInstallationSummary;

            return(container);
        }
Exemple #5
0
        public void ApplicationShouldBeInstalledTest_UseCase13()
        {
            // An install is not supposed to happen. Make sure the installer was not invoked.

            SetGlobalFreeze(false);

            ApplicationServer appServer = GetAppServerWithNoInstallationSummariesFromDb();

            ForceInstallation forceInstallation = new ForceInstallation();

            forceInstallation.ForceInstallationTime   = DateTime.Now.AddDays(-1);
            forceInstallation.ForceInstallEnvironment = // use an environment that's different than our app server's.
                                                        InstallationEnvironmentLogic.GetAll().Where(x => x.LogicalOrder != appServer.InstallationEnvironment.LogicalOrder).First();

            // Use this app and group
            ApplicationWithOverrideVariableGroup appWithGroup = appServer.ApplicationsWithOverrideGroup[0];

            appWithGroup.Application.ForceInstallation = forceInstallation;

            ApplicationServerLogic.InstallApplications(appServer);
            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }
Exemple #6
0
 public IEnumerable <InstallationEnvironment> GetAllInstallationEnvironments()
 {
     return(Invoke(() => InstallationEnvironmentLogic.GetAll()));
 }