コード例 #1
0
        public void ApplicationShouldBeInstalledTest_UseCase12()
        {
            // Use Case #12 -- force installation exists AT THE APP LEVEL, and the force installation time is *after* the most recent
            //                 installation summary time, *installation summaries exist*, and the deployment environments *match*.
            //                 The second test/assert is for when the global setting, FreezeAllInstallations, is true.

            TestEntityContainer container = CreateTestEntityContainer("UseCase12", x => x.InstallationStart.AddSeconds(1), true, false, 5);

            bool actual = ApplicationServerLogic.ApplicationShouldBeInstalled(container.ApplicationServer, container.AppWithGroup);

            Assert.AreEqual(true, actual);  // True because an installation has not yet occurred after the force deployment time.

            /*************************************************************************************
            * Now try it with FreezeAllInstallations true to override any installation logic.
            *************************************************************************************/

            SetGlobalFreeze(true);

            //bool actualUsingFreeze = ApplicationServerLogic.ApplicationShouldBeInstalled(container.ApplicationServer, container.AppWithGroup);
            //Assert.AreEqual(false, actualUsingFreeze);  // False because FreezeAllInstallations is true.

            ApplicationServerLogic.InstallApplications(container.ApplicationServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }
コード例 #2
0
        public void ApplicationShouldBeInstalledTest_UseCase7()
        {
            // Use Case #7 -- no force installation exists AT THE APP LEVEL

            // It doesn't really matter what we set here. We're getting rid of the ForceInstallation, so the app shouldn't get installed.
            TestEntityContainer container = CreateTestEntityContainer("UseCase07", x => DateTime.Now, true, false, 0);

            container.AppWithGroup.Application.ForceInstallation = null;

            ApplicationServerLogic.InstallApplications(container.ApplicationServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }
コード例 #3
0
        public void ApplicationShouldBeInstalledTest_UseCase10()
        {
            // Use Case #10 -- force installation exists AT THE APP LEVEL, and the force installation time is in the past,
            //                 no installation summaries exist, and the deployment environments *DO NOT* match.

            TestEntityContainer container = CreateTestEntityContainer("UseCase10", x => DateTime.Now.AddDays(-1), false, false, 0);

            //bool actual = ApplicationServerLogic.ApplicationShouldBeInstalled(container.ApplicationServer, container.AppWithGroup);
            //Assert.AreEqual(false, actual);

            ApplicationServerLogic.InstallApplications(container.ApplicationServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }
コード例 #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);
        }
コード例 #5
0
        public void ApplicationShouldBeInstalledTest_UseCase11()
        {
            // Use Case #11 -- force installation exists AT THE APP LEVEL, and the force installation time is *before* the most recent
            //                 installation summary time, *installation summaries exist*, and the deployment environments *match*.

            TestEntityContainer container = CreateTestEntityContainer("UseCase11", x => x.InstallationStart.AddSeconds(-86400),
                                                                      true, false, 5); // 86400 seconds in a day

            //bool actual = ApplicationServerLogic.ApplicationShouldBeInstalled(container.ApplicationServer, container.AppWithGroup);
            //Assert.AreEqual(false, actual);  // False because an installation has occurred after the force deployment time.

            ApplicationServerLogic.InstallApplications(container.ApplicationServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }