public static void ValidateAddTaskProperties(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model, Assembly assembly) { CSharpCommonValidator.ValidateProperty(tree, model, CreateStep3Property()); var methodName = "AddTask"; CSharpCommonValidator.ValidateMethod(tree, model, methodName); }
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(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model, Assembly assembly) { Lesson2CommonValidator.ValidateAddTaskMethod(compilation, tree, model, assembly); var methodName = "CompleteTask"; CSharpCommonValidator.ValidateMethod(tree, model, methodName); ValidatorsExtensions.ExecuteSafe(() => { var viewModel = (dynamic)assembly.CreateInstance("DotvvmAcademy.Tutorial.ViewModels.Lesson2ViewModel"); var task = (dynamic)assembly.CreateInstance("DotvvmAcademy.Tutorial.ViewModels.TaskData"); task.Title = "New Task"; task.IsCompleted = false; viewModel.CompleteTask(task); if (!task.IsCompleted) { throw new CodeValidationException(Lesson2Texts.CompleteTaskMethodError); } }); }