public void JobExistsWithAssemblyQualifiedName() { ILog logger = GetLogger(); IAsyncCommandContainer container = new AsyncCommandContainer(new AsyncCommandItemTimeSpan(), logger); var asyncFunc = new Mock<IAsyncCommand> { DefaultValue = DefaultValue.Mock }; container.Add(asyncFunc.Object, "", asyncFunc.Object.DecoratedCommand.GetType()); bool exists = container.Exists("", asyncFunc.Object.DecoratedCommand.GetType()); Assert.IsTrue(exists); }
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 SettingInactiveJobWhenRunningThrowsException() { var func = new Mock<IAsyncCommand>(); ILog logger = GetLogger(); func.Setup(f => f.Progress).Returns(new FuncStatus { Status = StatusEnum.Running }); var container = new AsyncCommandContainer(new AsyncCommandItemTimeSpan(), logger); container.Add(func.Object, "", func.Object.GetType()); container.SetInactive("", func.Object.GetType()); }
public void SettingActiveJobWhenNotRunningThrowsException() { var func = new Mock<IAsyncCommand>(); ILog logger = GetLogger(); func.Setup(f => f.Progress.Status).Returns(StatusEnum.Finished); var container = new AsyncCommandContainer(new AsyncCommandItemTimeSpan(), logger); container.Add(func.Object, "", func.Object.GetType()); container.SetActive("", func.Object.GetType()); }
public void RemovingRunningJobReducesCount() { ILog logger = GetLogger(); IAsyncCommandContainer container = new AsyncCommandContainer(new AsyncCommandItemTimeSpan(), logger); var async = new Mock<IAsyncCommand>(); async.Setup(a => a.Progress.Status).ReturnsInOrder(StatusEnum.NotStarted, StatusEnum.Running); container.Add(async.Object, "", async.Object.GetType()); int originalCount = container.Count; container.Remove("", async.Object.GetType()); int newCount = container.Count; Assert.AreEqual(originalCount - 1, newCount); }
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); }