Example #1
0
        public Task <ITransportPeer> SelectOwner(IEnumerable <ITransportPeer> peers)
        {
            var ordered = PreferredNodes.Select(x => peers.FirstOrDefault(_ => _.NodeId == x))
                          .Where(x => x != null);

            StoryTellerAssert.Fail(!ordered.Any(), "No preferred nodes established for this test node");

            var assignment = new OrderedAssignment(Subject, ordered);

            return(assignment.SelectOwner());
        }
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     // Check if the string is a valid JSON object.
     if (Edges.IsNullOrInvalidJsonObject <IEnumerable <(string, string)> >())
     {
         yield return(new ValidationResult("The value is not a valid JSON string.", new List <string> {
             nameof(Edges)
         }));
     }
     // Check if the string is a valid JSON object.
     if (TargetNodes.IsNullOrInvalidJsonObject <IEnumerable <string> >())
     {
         yield return(new ValidationResult("The value is not a valid JSON string.", new List <string> {
             nameof(TargetNodes)
         }));
     }
     // Check if the string is a valid JSON object.
     if (PreferredNodes.IsNullOrInvalidJsonObject <IEnumerable <string> >())
     {
         yield return(new ValidationResult("The value is not a valid JSON string.", new List <string> {
             nameof(PreferredNodes)
         }));
     }
 }