Esempio n. 1
0
        public void Validate(ResolvedTreeRoot resolvedTreeRoot)
        {
            Lesson1CommonValidator.ValidateTextBoxBindings(resolvedTreeRoot);

            resolvedTreeRoot.GetDescendantControls <Button>().Single()
            .ValidateCommandBindingExpression(ButtonBase.ClickProperty, "Calculate()");

            var buttonTextBinding = resolvedTreeRoot.GetDescendantControls <Button>()
                                    .Select(c => c.GetValue(ButtonBase.TextProperty))
                                    .SingleOrDefault();

            if (buttonTextBinding == null)
            {
                throw new CodeValidationException(Lesson1Texts.ButtonDoesNotHaveText);
            }
        }
Esempio n. 2
0
        public void Validate(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model,
                             Assembly assembly)
        {
            CSharpCommonValidator.ValidateProperties(tree, model, Lesson1CommonValidator.CreateStep4Properties());

            var methodName = "Calculate";

            CSharpCommonValidator.ValidateMethod(tree, model, methodName);

            ValidatorsExtensions.ExecuteSafe(() =>
            {
                var viewModel     = (dynamic)assembly.CreateInstance("DotvvmAcademy.Tutorial.ViewModels.Lesson1ViewModel");
                viewModel.Number1 = 15;
                viewModel.Number2 = 30;
                viewModel.Calculate();

                if (viewModel.Result != 45)
                {
                    throw new CodeValidationException(Lesson1Texts.CommandResultError);
                }
            });
        }
 public void Validate(ResolvedTreeRoot resolvedTreeRoot)
 {
     Lesson1CommonValidator.ValidateBasicControls(resolvedTreeRoot);
 }
Esempio n. 4
0
 public void Validate(ResolvedTreeRoot resolvedTreeRoot)
 {
     Lesson1CommonValidator.ValidateTextBoxBindings(resolvedTreeRoot);
 }
 public void Validate(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model,
                      Assembly assembly)
 {
     CSharpCommonValidator.ValidateProperties(tree, model, Lesson1CommonValidator.CreateStep4Properties());
 }