コード例 #1
0
        public static void ConcurrentOperationsDoNotCorruptState()
        {
            var database = new AgentStore();

            RunActionConcurrently(() =>
            {
                for (var i = 0; i < 1000; i++)
                {
                    var id      = Guid.NewGuid();
                    var process = new Process();

                    Assert.That(database.IsAgentProcessActive(id, out _), Is.False);
                    Assert.That(database.IsReady(id, out _), Is.False);

                    database.AddAgent(id, process);
                    Assert.That(database.IsAgentProcessActive(id, out _), Is.True);
                    Assert.That(database.IsReady(id, out _), Is.False);

                    database.Register(new DummyTestAgent(id));
                    Assert.That(database.IsAgentProcessActive(id, out _), Is.True);
                    Assert.That(database.IsReady(id, out _), Is.True);

                    database.MarkProcessTerminated(process);
                    Assert.That(database.IsAgentProcessActive(id, out _), Is.False);
                    Assert.That(database.IsReady(id, out _), Is.False);
                }
            }, threadCount: Environment.ProcessorCount);
        }
コード例 #2
0
        public static void AgentIsRunningWhenStarted()
        {
            var database = new AgentStore();

            database.AddAgent(DummyAgent.Id, DummyProcess);
            Assert.That(database.IsAgentProcessActive(DummyAgent.Id, out var process), Is.True);
            Assert.That(process, Is.SameAs(DummyProcess));
        }
コード例 #3
0
        public static void AgentIsNotRunningWhenTerminated()
        {
            var database = new AgentStore();

            database.AddAgent(DummyAgent.Id, DummyProcess);
            database.Register(DummyAgent);
            database.MarkProcessTerminated(DummyProcess);
            Assert.That(database.IsAgentProcessActive(DummyAgent.Id, out _), Is.False);
        }
コード例 #4
0
        public static void AgentIsNotRunningWhenNotStarted()
        {
            var database = new AgentStore();

            Assert.That(database.IsAgentProcessActive(DummyAgent.Id, out _), Is.False);
        }
コード例 #5
0
ファイル: TestAgency.cs プロジェクト: jnm2/testcentric-gui
 internal bool IsAgentProcessActive(Guid agentId, out Process process)
 {
     return(_agentStore.IsAgentProcessActive(agentId, out process));
 }