Exemple #1
0
        protected async Task <ValidationResultsCM> Validate(ExplicitTerminalActivity activity, ActivityContext activityContext)
        {
            var activityPayload = activityContext.ActivityPayload;

            activityPayload.CrateStorage.Remove <ValidationResultsCM>();

            var currentValidationResults = activityPayload.CrateStorage.CrateContentsOfType <ValidationResultsCM>().FirstOrDefault();

            if (currentValidationResults == null)
            {
                currentValidationResults = new ValidationResultsCM();
                activityPayload.CrateStorage.Add(Crate.FromContent("Validation Results", currentValidationResults));
            }

            //var validationManager = new ValidationManager(currentValidationResults, null);
            //let's trigger validation by calling activate
            await activity.Activate(activityContext);

            return(activityPayload.CrateStorage.CrateContentsOfType <ValidationResultsCM>().FirstOrDefault());
        }
Exemple #2
0
 protected void AssertErrorMessage(ValidationResultsCM validationResults, string errorMessage)
 {
     Assert.IsTrue(validationResults.ValidationErrors.Any(x => x.ErrorMessage == errorMessage), $"Error message '{errorMessage}' is missing");
 }
 public ValidationManager(ICrateStorage payload)
 {
     _validationResults = new ValidationResultsCM();
     Payload            = payload;
 }