public void RemovalTimerStartsWhenJobIsAdded()
        {
            var func = new Mock<IAsyncCommand>();
            ILog logger = GetLogger();

            func.Setup(f => f.Progress.Status).Returns(StatusEnum.NotStarted);

            AsyncCommandContainer container = new AsyncCommandContainer(new AsyncCommandItemTimeSpan(), logger);

            IAsyncCommand a = new AsyncManager(func.Object, "", container);

            AsyncContainerItem item = container.GetContainerItem("", func.Object.GetType());
            Assert.IsTrue(item.Timer.Enabled);
        }
        public void JobRemovedFromContainerAfterRemovalTimeElapsed()
        {
            var wait = new ManualResetEvent(false);
            var asyncFunc = new Mock<IAsyncCommand>();
            var timeSpan = new Mock<IAsyncCommandItemTimeSpan>();
            ILog logger = GetLogger();

            asyncFunc.Setup(a => a.Progress.Status).Returns(StatusEnum.Finished);
            timeSpan.Setup(t => t.Time).Returns(new TimeSpan(0, 0, 0, 0, 1));

            var container = new AsyncCommandContainer(timeSpan.Object, logger);

            container.Add(asyncFunc.Object, "", asyncFunc.Object.GetType());

            container.SetInactive("", asyncFunc.Object.GetType());
            container.GetContainerItem("", asyncFunc.Object.GetType()).OnItemRemoved += () => wait.Set();

            wait.WaitOne(3000);

            Assert.IsFalse(container.Exists("", asyncFunc.Object.GetType()));
        }
        public void RemovalTimerSetToCorrectRemovalMinutesWhenAdded()
        {
            ILog logger = GetLogger();
            AsyncCommandContainer container = new AsyncCommandContainer(new AsyncCommandItemTimeSpan(), logger);
            var asyncFunc = new Mock<IAsyncCommand> { DefaultValue = DefaultValue.Mock };

            TimeSpan removalTime = Properties.Settings.Default.ContainerRemovalTime;

            container.Add(asyncFunc.Object, "", asyncFunc.Object.DecoratedCommand.GetType());
            AsyncContainerItem item = container.GetContainerItem("", asyncFunc.Object.DecoratedCommand.GetType());

            Assert.AreEqual(item.Timer.Interval, removalTime.TotalMilliseconds);
        }