public void RemoveApplicationsByTimeCreatedTestRemoveMultipleOldApplications()
        {
            Maintenance maintenance = new Maintenance();

            DateTime timeCreated = DateTime.Now;

            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated.AddDays(-5), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Stopped, timeCreated.AddDays(-4), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Ready, timeCreated.AddDays(1), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated.AddDays(-3), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Stopped, timeCreated.AddDays(2), false, "username1"));

            Assert.AreEqual(5, m_managerStorage.GetApplications().Length);

            maintenance.RemoveApplications(m_managerStorage, timeCreated);

            Assert.AreEqual(2, m_managerStorage.GetApplications().Length);
        }
        public void RemoveApplicationsByTimeCreatedTestRemoveNonExistingDates()
        {
            Maintenance maintenance = new Maintenance();
            DateTime timeCreated = DateTime.Now;

            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated, false, "username1"));

            Assert.AreEqual(1, m_managerStorage.GetApplications().Length);

            maintenance.RemoveApplications(m_managerStorage, timeCreated.AddDays(-1));

            Assert.AreEqual(1, m_managerStorage.GetApplications().Length);
        }
        public void RemoveApplicationsByTimeCreatedTestNothingToRemove()
        {
            Maintenance maintenance = new Maintenance();

            Assert.AreEqual(0, m_managerStorage.GetApplications().Length);

            maintenance.RemoveApplications(m_managerStorage, DateTime.Now);

            Assert.AreEqual(0, m_managerStorage.GetApplications().Length);
        }
        public void RemoveApplicationsByTimeCreatedSpanTestRemoveNonExistingDates()
        {
            Maintenance maintenance = new Maintenance();
            DateTime timeCreated = DateTime.Now;

            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated, false, "username1"));

            Assert.AreEqual(1, m_managerStorage.GetApplications().Length);

            // one hour should be enough to avoid removing this one.
            maintenance.RemoveApplications(m_managerStorage, new TimeSpan(1, 0, 0));

            Assert.AreEqual(1, m_managerStorage.GetApplications().Length);
        }
        public void RemoveApplicationsByTimeCreatedSpanTestRemoveMultipleOldApplications()
        {
            Maintenance maintenance = new Maintenance();

            DateTime timeCreated = DateTime.Now;

            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated.AddDays(-5), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Stopped, timeCreated.AddDays(-4), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Ready, timeCreated.AddDays(1), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated.AddDays(-3), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Stopped, timeCreated.AddDays(2), false, "username1"));

            Assert.AreEqual(5, m_managerStorage.GetApplications().Length);

            // put a 20 hour cut-off, this should remove 3 of the applications
            maintenance.RemoveApplications(m_managerStorage, new TimeSpan(20, 0, 0));

            Assert.AreEqual(2, m_managerStorage.GetApplications().Length);
        }
        public void RemoveApplicationsByApplicationStateTestRemoveOneExistingState()
        {
            Maintenance maintenance = new Maintenance();

            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, DateTime.Now, false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Stopped, DateTime.Now, false, "username1"));

            Assert.AreEqual(2, m_managerStorage.GetApplications().Length);

            maintenance.RemoveApplications(m_managerStorage, ApplicationState.Stopped);

            Assert.AreEqual(1, m_managerStorage.GetApplications().Length);
        }
        public void RemoveApplicationsByApplicationStateTestNothingToRemove()
        {
            Maintenance maintenance = new Maintenance();

            Assert.AreEqual(0, m_managerStorage.GetApplications().Length);

            maintenance.RemoveApplications(m_managerStorage);

            Assert.AreEqual(0, m_managerStorage.GetApplications().Length);
        }