Esempio n. 1
0
        public Task <TaskHealthResponse> CheckStatusOfOwnedTasks()
        {
            var response = new TaskHealthResponse
            {
                Tasks = OwnedSubjects.Select(uri => new PersistentTaskStatus
                {
                    Status  = SubjectStatus[uri],
                    Subject = uri
                }).ToArray()
            };

            return(response.ToCompletionTask());
        }
        public void build_for_errors()
        {
            var response = TaskHealthResponse.ErrorFor(new[] { subject1, subject2, subject3, subject4 });

            response.Tasks.ShouldHaveTheSameElementsAs(
                new PersistentTaskStatus(subject1, HealthStatus.Error),
                new PersistentTaskStatus(subject2, HealthStatus.Error),
                new PersistentTaskStatus(subject3, HealthStatus.Error),
                new PersistentTaskStatus(subject4, HealthStatus.Error)

                );

            response.ResponseFailed.ShouldBeTrue();
        }
        public void add_missing_subjects_no_change()
        {
            var response = new TaskHealthResponse
            {
                Tasks = new[]
                {
                    new PersistentTaskStatus(subject1, HealthStatus.Active),
                    new PersistentTaskStatus(subject2, HealthStatus.Active),
                    new PersistentTaskStatus(subject3, HealthStatus.Active),
                    new PersistentTaskStatus(subject4, HealthStatus.Active),
                }
            };

            response.AddMissingSubjects(new [] { subject1, subject2, subject3, subject4 });

            response.Tasks.Count().ShouldEqual(4);
        }
        public void add_missing_subjects_with_gaps()
        {
            var response = new TaskHealthResponse
            {
                Tasks = new[]
                {
                    new PersistentTaskStatus(subject1, HealthStatus.Active),
                    //new PersistentTaskStatus(subject2, HealthStatus.Active),
                    //new PersistentTaskStatus(subject3, HealthStatus.Active),
                    new PersistentTaskStatus(subject4, HealthStatus.Active),
                }
            };

            response.AddMissingSubjects(new[] { subject1, subject2, subject3, subject4 });

            response.Tasks.Count().ShouldEqual(4);

            response.Tasks.ShouldContain(new PersistentTaskStatus(subject2, HealthStatus.Inactive));
            response.Tasks.ShouldContain(new PersistentTaskStatus(subject3, HealthStatus.Inactive));
        }
Esempio n. 5
0
        protected override void theContextIs()
        {
            var subjects = new Uri[] { subject1, subject2, subject3, subject4 };

            theNode.OwnedTasks = subjects;

            theResponse = new TaskHealthResponse
            {
                Tasks = new PersistentTaskStatus[0]
            };


            theServiceBus.ExpectMessage(new TaskHealthRequest {
                Subjects = subjects
            })
            .AtDestination(theNode.ControlChannel)
            .Returns(theResponse);

            theReturnedTask = thePeer.CheckStatusOfOwnedTasks();
            theReturnedTask.Wait();
        }
Esempio n. 6
0
        protected override void theContextIs()
        {
            var subjects = new Uri[] { subject1, subject2, subject3, subject4 };

            theNode.OwnedTasks = subjects;

            theResponse = new TaskHealthResponse
            {
                Tasks = subjects.Select(x => new PersistentTaskStatus(x, HealthStatus.Active)).ToArray()
            };


            theServiceBus.ExpectMessage(new TaskHealthRequest {
                Subjects = subjects
            })
            .AtDestination(theNode.Addresses.First())
            .Returns(theResponse);

            theReturnedTask = thePeer.CheckStatusOfOwnedTasks();
            theReturnedTask.Wait();
        }