Beispiel #1
0
        public void Abc()
        {
            var agentId     = Guid.NewGuid();
            var decomponser = new DecomposerStub(agentId).WithHD();

            var hdScanTargets = new[]
            {
                new ScanTarget(agentId, "192.168.2.0"),
                new ScanTarget(agentId, "192.168.2.1"),
                new ScanTarget(agentId, "192.168.2.2"),
            };

            var actorRepositoryStub = new AgentGatewayActorRepositoryStub()
                                      .WithCreateActorFunc(
                id => new AgentGatewayActorStub(id).WithJobResultsFunc(sj => GetHDJobResults(sj, hdScanTargets)));

            var taskId      = Guid.NewGuid();
            var testContext = new TestContext(decomponser, actorRepositoryStub)
                              .WithAgent(agentId)
                              .WithTask(taskId);

            var taskRunId = Guid.NewGuid();

            testContext.Dispatch(new Notification(ActorTypes.Task, taskId, new RunTask(taskId, taskRunId, true)));

            Assert.True(testContext.WaitTaskRunFinished(taskRunId, 5));
            Assert.True(testContext.WaitJobsFinished(taskRunId, hdScanTargets, 5));
        }
Beispiel #2
0
        public TestContext(IDecomposer decomposer, AgentGatewayActorRepositoryStub agentGatewayActorRepositoryStub)
        {
            _taskRunRepository = new TaskRunRepository(decomposer);
            _taskRepository    = new TaskRepository();
            _agentRepository   = new AgentRepository(_taskRunRepository);

            var notificationRepository = new NotificationRepository();

            var actorRepositoryLocator = new ActorUnitOfWorkLocator(
                new UnitOfWork(ActorTypes.Agent, _agentRepository, notificationRepository),
                new UnitOfWork(ActorTypes.Task, _taskRepository, notificationRepository),
                new UnitOfWork(ActorTypes.TaskRun, _taskRunRepository, notificationRepository),
                new UnitOfWork(ActorTypes.AgentJobGateway, agentGatewayActorRepositoryStub, notificationRepository));

            _actorDispatcher = new ActorDispatcher(
                actorRepositoryLocator,
                CancellationToken.None);
        }