示例#1
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);
        }
示例#2
0
        public void ApplicationShouldBeInstalledTest_UseCase14()
        {
            // An install is supposed to happen. Make sure the installer was invoked.

            SetGlobalFreeze(false);

            ApplicationServer appServer = GetAppServerWithNoInstallationSummariesFromDb();

            ForceInstallation forceInstallation = new ForceInstallation();

            forceInstallation.ForceInstallationTime   = DateTime.Now.AddDays(-1);
            forceInstallation.ForceInstallEnvironment = appServer.InstallationEnvironment;  // Make environments match

            // 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.Once());
        }
示例#3
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());
        }