public void Validate(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model,
                             Assembly assembly)
        {
            Lesson4CommonValidator.ValidateStep12(tree, model, assembly);


            ValidatorsExtensions.ExecuteSafe(() =>
            {
                var viewModel = (dynamic)assembly.CreateInstance("DotvvmAcademy.Tutorial.ViewModels.Lesson4ViewModel");

                var now = DateTime.UtcNow;

                viewModel.SubscriptionFrom = now.AddDays(3);
                viewModel.SubscriptionTo   = now;

                IEnumerable <ValidationResult> validationResults = viewModel.Validate(null);
                if (!validationResults.Any())
                {
                    throw new CodeValidationException(Lesson4Texts.IncorrectValidationRule);
                }
                viewModel.SubscriptionFrom = now;
                viewModel.SubscriptionTo   = now.AddDays(5);

                validationResults = viewModel.Validate(null);
                if (validationResults.Any())
                {
                    throw new CodeValidationException(Lesson4Texts.IncorrectValidationRule);
                }
            });
        }
Example #2
0
 public void Validate(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model,
                      Assembly assembly)
 {
     Lesson4CommonValidator.ValidateStep12(tree, model, assembly);
 }