public void Validate(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model, Assembly assembly) { var propertiesToValidate = Lesson3CommonValidator.CreateStep4Properties(); CSharpCommonValidator.ValidateProperties(tree, model, propertiesToValidate); }
public void Validate(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model, Assembly assembly) { var className = "CountryInfo"; CSharpCommonValidator.ValidateClass(tree, model, className); CSharpCommonValidator.ValidateProperties(tree, model, Lesson3CommonValidator.CreateStep8Properties()); }
public void Validate(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model, Assembly assembly) { var properties = Lesson3CommonValidator.CreateOnlyStep9Properties(); properties.Add(Lesson3CommonValidator.CreateNewCustomerProperty()); CSharpCommonValidator.ValidateProperties(tree, model, properties); }
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 static void ValidateStep11Properties(CSharpSyntaxTree tree, SemanticModel model, Assembly assembly) { ValidateStep2Properties(tree, model, assembly); var propertiesToValidate = new List <Property> { new Property("SubscriptionFrom", "System.DateTime", ControlBindName.DivClass), new Property("SubscriptionTo", "System.DateTime", ControlBindName.DivClass) }; CSharpCommonValidator.ValidateProperties(tree, model, propertiesToValidate); }
public void Validate(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model, Assembly assembly) { var taskdata = "TaskData"; CSharpCommonValidator.ValidateClass(tree, model, taskdata); List <Property> propertiesToValidate = Lesson2CommonValidator.CreateStep5Properties(); CSharpCommonValidator.ValidateProperties(tree, model, propertiesToValidate); }
public void Validate(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model, Assembly assembly) { CSharpCommonValidator.ValidateProperties(tree, model, Lesson3CommonValidator.CreateStep9Properties()); ValidatorsExtensions.ExecuteSafe(() => { var viewModel = (dynamic)assembly.CreateInstance("DotvvmAcademy.Tutorial.ViewModels.Lesson3ViewModel"); var usa = viewModel?.Countries[0]; if (usa == null || usa.Name != "USA" || usa.Id != 1) { throw new CodeValidationException(string.Format(Lesson3Texts.CountryInfoError, "USA", 1)); } var canada = viewModel?.Countries[1]; if (canada == null || canada.Name != "Canada" || canada.Id != 2) { throw new CodeValidationException(string.Format(Lesson3Texts.CountryInfoError, "Canada", 2)); } }); }
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); } }); }
public static void ValidateStep2Properties(CSharpSyntaxTree tree, SemanticModel model, Assembly assembly) { CSharpCommonValidator.ValidateProperties(tree, model, CreateStep2ControlProperties()); ValidatorsExtensions.ExecuteSafe(() => { var viewModel = (dynamic)assembly.CreateInstance("DotvvmAcademy.Tutorial.ViewModels.Lesson4ViewModel"); var modelProperties = (viewModel.GetType().GetProperties() as IEnumerable <PropertyInfo>).ToList(); foreach (var requiredProperty in CreateStep2RequiredProperties()) { var viewModelProperty = modelProperties.FirstOrDefault(a => a.Name == requiredProperty.Name); if (viewModelProperty == null) { throw new CodeValidationException(string.Format(ValidationErrorMessages.PropertyNotFound, requiredProperty.Name)); } if (!viewModelProperty.IsDefined(typeof(RequiredAttribute))) { throw new CodeValidationException(string.Format(Lesson4Texts.AttributeMissing, requiredProperty.Name, nameof(RequiredAttribute))); } } var emailPropertyName = CreateStep2EmailAddressProperty().Name; var emailProperty = modelProperties.FirstOrDefault(a => a.Name == emailPropertyName); if (emailProperty == null) { throw new CodeValidationException(string.Format(ValidationErrorMessages.PropertyNotFound, emailPropertyName)); } if (!emailProperty.IsDefined(typeof(EmailAddressAttribute))) { throw new CodeValidationException(string.Format(Lesson4Texts.AttributeMissing, emailPropertyName, nameof(EmailAddressAttribute))); } }); }
public static void ValidateStep12(CSharpSyntaxTree tree, SemanticModel model, Assembly assembly) { ValidateStep11Properties(tree, model, assembly); CSharpCommonValidator.ValidateClassIfImplementInterface(tree, model, "Lesson4ViewModel", "IValidatableObject"); }
public static void ValidateTasksProperty(CSharpCompilation compilation, CSharpSyntaxTree tree, SemanticModel model, Assembly assembly) { ValidateAddTaskProperties(compilation, tree, model, assembly); CSharpCommonValidator.ValidateProperty(tree, model, CreateStep6Property()); }