public static void AgentIsNotReadyWhenStarted()
        {
            var database = new AgentStore();

            database.AddAgent(DummyAgent.Id, DummyProcess);
            Assert.That(database.IsReady(DummyAgent.Id, out _), Is.False);
        }
        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);
        }
        public static void AgentMustNotRegisterAfterTerminating()
        {
            var database = new AgentStore();

            database.AddAgent(DummyAgent.Id, DummyProcess);
            database.MarkProcessTerminated(DummyProcess);
            Assert.That(() => database.Register(DummyAgent), Throws.ArgumentException.With.Property("ParamName").EqualTo("agent"));
        }
        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));
        }
        public static void AgentIsNotReadyWhenTerminated()
        {
            var database = new AgentStore();

            database.AddAgent(DummyAgent.Id, DummyProcess);
            database.Register(DummyAgent);
            database.MarkProcessTerminated(DummyProcess);
            Assert.That(database.IsReady(DummyAgent.Id, out _), Is.False);
        }
        public static void AgentIsReadyWhenRegistered()
        {
            var database = new AgentStore();

            database.AddAgent(DummyAgent.Id, DummyProcess);
            database.Register(DummyAgent);
            Assert.That(database.IsReady(DummyAgent.Id, out var registeredAgent), Is.True);
            Assert.That(registeredAgent, Is.SameAs(DummyAgent));
        }
Exemple #7
0
        public static void AgentIsNotRunningWhenTerminated()
        {
            var database = new AgentStore();

            database.AddAgent(DummyAgent.Id, DummyProcess);
            database.Register(DummyAgent);
            database.MarkTerminated(DummyAgent.Id);
            Assert.That(database.IsAgentProcessActive(DummyAgent.Id, out _), Is.False);
        }
Exemple #8
0
        public static void IdCannotBeReused()
        {
            var database = new AgentStore();

            database.AddAgent(DummyAgent.Id, DummyProcess);
            Assert.That(() => database.AddAgent(DummyAgent.Id, DummyProcess), Throws.ArgumentException.With.Property("ParamName").EqualTo("agentId"));

            database.Register(DummyAgent);
            Assert.That(() => database.AddAgent(DummyAgent.Id, DummyProcess), Throws.ArgumentException.With.Property("ParamName").EqualTo("agentId"));

            database.MarkTerminated(DummyAgent.Id);
            Assert.That(() => database.AddAgent(DummyAgent.Id, DummyProcess), Throws.ArgumentException.With.Property("ParamName").EqualTo("agentId"));
        }
        public static void AgentMustBeStartedBeforeTerminating()
        {
            var database = new AgentStore();

            Assert.That(() => database.MarkProcessTerminated(DummyProcess), Throws.ArgumentException.With.Property("ParamName").EqualTo("process"));
        }
        public static void AgentMustBeStartedBeforeRegistering()
        {
            var database = new AgentStore();

            Assert.That(() => database.Register(DummyAgent), Throws.ArgumentException.With.Property("ParamName").EqualTo("agent"));
        }
        public static void AgentIsNotRunningWhenNotStarted()
        {
            var database = new AgentStore();

            Assert.That(database.IsAgentProcessActive(DummyAgent.Id, out _), Is.False);
        }
        public static void AgentIsNotReadyWhenNotStarted()
        {
            var database = new AgentStore();

            Assert.That(database.IsAvailable(DummyAgent.Id, out _), Is.False);
        }