public ProjectUpdateHandler(GlobalSolusindoDb db, tblM_User user, ProjectValidator projectValidator, ProjectFactory projectFactory, ProjectQuery projectQuery, AccessControl accessControl) : base(db, user) { this.projectValidator = projectValidator; this.projectFactory = projectFactory; this.projectQuery = projectQuery; this.projectEntryDataProvider = new ProjectEntryDataProvider(db, user, accessControl, projectQuery); }
public int Execute(string loadProject) { try { Project project = new Project(loadProject); ProjectValidator validator = new ProjectValidator(project); project.Load(); validator.Validate(); PrintResultsOfType(validator, ValidationResultType.Error, Colors.Red); PrintResultsOfType(validator, ValidationResultType.Warning, Color.FromRgb(165, 176, 9)); PrintResultsOfType(validator, ValidationResultType.Info, Colors.Blue); return(0); } catch (Exception ex) { AppendText(txtResult, "Error Occurred", Colors.Red); StringBuilder strBuild = new StringBuilder(); strBuild.AppendLine("Exception Details"); strBuild.AppendLine("Source: " + ex.Source); strBuild.AppendLine("Message: " + ex.Message); strBuild.AppendLine("StackTrace: " + ex.StackTrace); AppendText(txtResult, strBuild.ToString(), Colors.Red); return(-1); } }
public void Execute_IntegrationTest_SQLite() { string filePath = Path.Combine(AppContext.BaseDirectory, Path.GetRandomFileName() + ".dbtest"); using (SQLiteDbContext dbContext = new SQLiteDbContext(filePath)) { dbContext.Initialise(); dbContext.BeginTransaction(); IProjectValidator projectValidator = new ProjectValidator(); IProjectRequestAggregateValidator validator = new ProjectRequestAggregateValidator(); ISetLogFileUnprocessedCommand setLogFileUnprocessedCommand = Substitute.For <ISetLogFileUnprocessedCommand>(); ICreateProjectRequestAggregateCommand createProjectRequestAggregateCommand = new CreateProjectRequestAggregateCommand(dbContext, validator, new LogFileRepository(dbContext), setLogFileUnprocessedCommand); // create the project first so we have one ProjectModel project = DataHelper.CreateProjectModel(); DataHelper.InsertProjectModel(dbContext, project); // create the request aggregate ProjectRequestAggregateModel projectRequestAggregate = DataHelper.CreateProjectRequestAggregateModel(); projectRequestAggregate.ProjectId = project.Id; createProjectRequestAggregateCommand.Execute(projectRequestAggregate); Assert.Greater(projectRequestAggregate.Id, 0); int rowCount = dbContext.ExecuteScalar <int>("SELECT COUNT(*) FROM ProjectRequestAggregates"); Assert.Greater(rowCount, 0); ProjectRequestAggregateModel savedModel = dbContext.Query <ProjectRequestAggregateModel>("SELECT * FROM ProjectRequestAggregates WHERE Id = @Id", new { Id = projectRequestAggregate.Id }).Single(); Assert.AreEqual(projectRequestAggregate.RegularExpression, savedModel.RegularExpression); Assert.AreEqual(projectRequestAggregate.AggregateTarget, savedModel.AggregateTarget); } }
private async Task GoBack() { // display Alert for confirmation if (IsChanged) { ProjectValidator _projectValidator = new ProjectValidator(); ValidationResult validationResults = _projectValidator.Validate(_project); if (validationResults.IsValid) { AddProject(); Shell.Current.Navigating -= Current_Navigating; // await Shell.Current.GoToAsync("..", true); await _navigation.PopAsync(true); } else { await Application.Current.MainPage.DisplayAlert("Add Project", validationResults.Errors[0].ErrorMessage, "Ok"); } } else { Shell.Current.Navigating -= Current_Navigating; // await Shell.Current.GoToAsync("..", true); await _navigation.PopAsync(true); } }
public void Validate(Project project, IValidationRecipient validationRecipient) { var repository = RepositoryFactory.GetRepository <IProjectRepository>(); var validator = new ProjectValidator(project, validationRecipient, repository.GetQueryable()); validator.Validate(); }
private async Task GoBack() { // display Alert for confirmation if (IsChanged) { ProjectValidator _Validator = new ProjectValidator(); ValidationResult validationResults = _Validator.Validate(_project); if (validationResults.IsValid) { _ = Update(); //just to slow things down _project = _projectRepository.GetProjectData(_project.PROJECTID); Shell.Current.Navigating -= Current_Navigating; // await Shell.Current.GoToAsync("..", true); await _navigation.PopAsync(true); } else { await Application.Current.MainPage.DisplayAlert("Update Project", validationResults.Errors[0].ErrorMessage, "Ok"); } } else { Shell.Current.Navigating -= Current_Navigating; // await Shell.Current.GoToAsync("..", true); await _navigation.PopAsync(true); } }
public static Project From(EntityId id, ProjectName name, ProjectCode code, DateAndTime startDate, Money budget, EntityId clientId, Email owner, ProjectStatus status, ServiceOrderNumber orderNumber, Version version) { var project = new Project(id, name, code, startDate, budget, clientId, owner, status, orderNumber, version); var validator = new ProjectValidator(); project.SetValidationResult(validator.Validate(project)); return(project); }
public AddProjectViewModel(INavigation navigation) { _navigation = navigation; _projectValidator = new ProjectValidator(); _project = new PROJECT(); _projectRepository = new ProjectRepository(); AddProjectCommand = new Command(async() => await AddProject()); ViewAllProjectsCommand = new Command(async() => await ShowProjectList()); }
public ConsoleView() { IUnityContainer container = new UnityContainer(); container.RegisterType <IEmployeeRepository, EmployeeRepository>(new ContainerControlledLifetimeManager()); employeeValidator = container.Resolve <EmployeeValidator>(); container.RegisterType <IProjectRepository, ProjectRepository>(new ContainerControlledLifetimeManager()); projectValidator = container.Resolve <ProjectValidator>(); }
static public int Execute(string loadProject) { Project project = new Project(loadProject); ProjectValidator validator = new ProjectValidator(project); project.Load(); validator.Validate(); return(0); }
protected ProjectCodeTestConfig(DbContextOptions <ApiContext> contextOptions) { this.contextOptions = contextOptions; projectValidatorMock = new Mock <IProjectValidator>(); projectValidator = new ProjectValidator(new ApiContext(contextOptions)); CreateMapper(); Seed(); }
public int Execute() { Project project = new Project(Project); ProjectValidator validator = new ProjectValidator(project); ConsoleColor foregroundBackup = Console.ForegroundColor; ConsoleColor backgroundBackup = Console.BackgroundColor; switch (backgroundBackup) { case ConsoleColor.Black: break; case ConsoleColor.Blue: case ConsoleColor.DarkBlue: foregroundColor = ConsoleColor.White; infoColor = ConsoleColor.Cyan; break; default: Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = foregroundColor; break; } Console.WriteLine("Loading info..."); project.Load(); Console.WriteLine("Starting validation on project {0}.", project.Name); validator.Validate(); Console.WriteLine("Validation finished. Printing results."); if (!HideError) { PrintResultsOfType(validator, ValidationResultType.Error); } if (!HideWarning) { PrintResultsOfType(validator, ValidationResultType.Warning); } if (!HideInfo) { PrintResultsOfType(validator, ValidationResultType.Info); } Console.ForegroundColor = foregroundColor; Console.WriteLine(); Console.WriteLine("Total number of situations found: {0}", validator.Count()); Console.ForegroundColor = foregroundBackup; Console.BackgroundColor = backgroundBackup; return(0); }
public async Task IsClosedForTagAsync_KnownTag_ShouldReturnTrue() { using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new ProjectValidator(context); var result = await dut.IsClosedForTagAsync(_tagInClosedProjectId, default); Assert.IsTrue(result); } }
public async Task ExistsAsync_KnownName_ShouldReturnTrue() { using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new ProjectValidator(context); var result = await dut.ExistsAsync(ProjectNameNotClosed, default); Assert.IsTrue(result); } }
private bool ValidateDataResponsibleProject() { ProjectValidator projectValidator = new ProjectValidator(); ValidationResult dataValidationResult = projectValidator.Validate(_project); IList <ValidationFailure> validationFailures = dataValidationResult.Errors; UserFeedback userFeedback = new UserFeedback(FormGrid, validationFailures); userFeedback.ShowFeedback(); return(dataValidationResult.IsValid); }
public async Task IsExistingAndClosedAsync_UnknownName_ShouldReturnFalse() { using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new ProjectValidator(context); var result = await dut.IsExistingAndClosedAsync("XX", default); Assert.IsFalse(result); } }
public void Validate() { var validator = new ProjectValidator(); var validationResult = validator.Validate(this); if (!validationResult.IsValid) { throw new ValidationException(string.Join(";", validationResult.Errors.Select(i => i.ErrorCode))); } }
private void PrintResultsOfType(ProjectValidator validator, ValidationResultType type) { var filteredResults = validator.GetResultsByType(type); Console.WriteLine(); WriteTypeCount(type, filteredResults.Count()); foreach (var item in filteredResults) { WriteValidationResult(item); } }
public async Task AllTagsInSameProjectAsync_TagsInSameProject_ShouldReturnTrue() { using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new ProjectValidator(context); var result = await dut.AllTagsInSameProjectAsync(new List <int> { _tag1InNotClosedProjectId, _tag2InNotClosedProjectId }, default); Assert.IsTrue(result); } }
public async Task AllTagsInSameProjectAsync_UnknownTag_ShouldReturnFalse() { using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new ProjectValidator(context); var result = await dut.AllTagsInSameProjectAsync(new List <int> { 0 }, default); Assert.IsFalse(result); } }
public AddProjectViewModel(INavigation navigation) { _navigation = navigation; _projectValidator = new ProjectValidator(); _project = new PROJECT(); _projectRepository = new ProjectRepository(); AddProjectCommand = new Command(() => AddProject()); ViewAllProjectsCommand = new Command(async() => await ShowProjectList()); _project.PROJECT_DATE = DateTime.Now; IsChanged = false; OnAppearingCommand = new Command(() => OnAppearing()); OnDisappearingCommand = new Command(() => OnDisappearing()); }
public ActionResult <Project> AddProject([FromBody] Project project) { var projects = _context.Project; if (ProjectValidator.IsProjectNameExists(project)) { return(BadRequest(ErrorHandler.GenerateError(ErrorHandler.ProjectNameEsists))); } projects.Add(project); _context.SaveChanges(); return(project); }
public void ValidatePositiveTest() { var project = new Project() { ProjectName = "Test", ProjectStartDate = DateTime.Now.AddDays(1), ProjectEndDate = DateTime.Now.AddDays(1), }; _projectValidator = new ProjectValidator(); var result = _projectValidator.Validate(project); Assert.True(result); }
public void ValidateNegativeEndDateIsEarlierThanStartDateTest() { var project = new Project() { ProjectName = "Test", ProjectStartDate = DateTime.Now.AddDays(2), ProjectEndDate = DateTime.Now.AddDays(1), }; _projectValidator = new ProjectValidator(); var result = _projectValidator.Validate(project); Assert.False(result); }
private bool ValidateDataProject() { _isValidSchedulingActivity = true; _listSchedulingActivity = new List <SchedulingActivity>(); ProjectValidator projectValidator = new ProjectValidator(); ValidationResult dataValidationResult = projectValidator.Validate(_project); IList <ValidationFailure> validationFailures = dataValidationResult.Errors; UserFeedback userFeedback = new UserFeedback(FormGrid, validationFailures); userFeedback.ShowFeedback(); ValidateScheduleActivity(TextBoxScheduleActivityOne, LabelMonth1.Content.ToString()); ValidateScheduleActivity(TextBoxScheduleActivityTwo, LabelMonth2.Content.ToString()); ValidateScheduleActivity(TextBoxScheduleActivityThree, LabelMonth3.Content.ToString()); ValidateScheduleActivity(TextBoxScheduleActivityFour, LabelMonth4.Content.ToString()); return(dataValidationResult.IsValid && _isValidSchedulingActivity && _listSchedulingActivity.Count != 0); }
private void PrintResultsOfType(ProjectValidator validator, ValidationResultType type, Color color) { var filteredResults = validator.GetResultsByType(type); StringBuilder strBuild = new StringBuilder(); if (filteredResults.Count() > 0) { strBuild.AppendLine(filteredResults.Count().ToString() + " " + type + " messages:"); foreach (var item in filteredResults) { strBuild.AppendLine(item.FormattedMessage); } AppendText(txtResult, strBuild.ToString(), color); } }
public ActionResult <MentorRequest> CreateRequest([FromBody] MentorRequestParams requestParams) { if (!MentorValidator.IsMentorExists(requestParams.MentorID)) { return(BadRequest(ErrorHandler.GenerateError(ErrorHandler.MentorNotFound))); } if (!ProjectValidator.IsProjectExists(requestParams.ProjectID)) { return(BadRequest(ErrorHandler.GenerateError(ErrorHandler.ProjectNotFound))); } if (MentorRequestValidator.IsExistsRequest(requestParams)) { return(BadRequest(ErrorHandler.GenerateError(ErrorHandler.MentorRequestExists))); } return(_mentorRequestRepo.CreateRequest(requestParams)); }
public void Execute_IntegrationTest_SQLite() { string dbPath = Path.Combine(AppContext.BaseDirectory, Path.GetRandomFileName() + ".dbtest"); using (SQLiteDbContext dbContext = new SQLiteDbContext(dbPath)) { dbContext.Initialise(); dbContext.BeginTransaction(); // create the project first so we have one ProjectModel project = DataHelper.CreateProjectModel(); IProjectValidator projectValidator = new ProjectValidator(); ILogFileRepository logFileRepo = new LogFileRepository(dbContext); int projectId = new Random().Next(1, 1000); string filePath = Path.Combine(AppContext.BaseDirectory, Path.GetRandomFileName() + ".log"); FileDetail fileDetail = new FileDetail(); fileDetail.Length = new Random().Next(1000, 10000); fileDetail.Hash = Guid.NewGuid().ToString(); fileDetail.Name = Guid.NewGuid().ToString(); _fileUtils.GetFileHash(filePath).Returns(fileDetail); DataHelper.InsertProjectModel(dbContext, project); // create the log file LogFileModel logFile = DataHelper.CreateLogFileModel(); logFile.ProjectId = project.Id; ILogFileValidator logFileValidator = new LogFileValidator(); ICreateLogFileCommand createLogFileCommand = new CreateLogFileCommand(dbContext, logFileValidator, logFileRepo, _jobRegistrationService, _fileUtils); LogFileModel savedLogFile = createLogFileCommand.Execute(project.Id, filePath); Assert.Greater(savedLogFile.Id, 0); int rowCount = dbContext.ExecuteScalar <int>("SELECT COUNT(*) FROM LogFiles"); Assert.Greater(rowCount, 0); string fileName = dbContext.ExecuteScalar <string>("SELECT FileName FROM LogFiles WHERE Id = @Id", savedLogFile); Assert.AreEqual(savedLogFile.FileName, fileName); Assert.AreEqual(LogFileStatus.Processing, savedLogFile.Status); } }
async Task UpdateProject() { // var validationResults = _projectValidator.Validate(_project); ProjectValidator _projectValidator = new ProjectValidator(); ValidationResult validationResults = _projectValidator.Validate(_project); if (validationResults.IsValid) { bool isUserAccept = await Application.Current.MainPage.DisplayAlert("Project Details", "Update Project Details", "OK", "Cancel"); if (isUserAccept) { _project.LastModified = System.DateTime.UtcNow; _projectRepository.UpdateProject(_project); await _navigation.PopAsync(); } } else { await Application.Current.MainPage.DisplayAlert("Add Project", validationResults.Errors[0].ErrorMessage, "Ok"); } }
public void Execute_IntegrationTest_SQLite() { string filePath = Path.Combine(AppContext.BaseDirectory, Path.GetRandomFileName() + ".dbtest"); using (SQLiteDbContext dbContext = new SQLiteDbContext(filePath)) { dbContext.Initialise(); dbContext.BeginTransaction(); ProjectModel project = DataHelper.CreateProjectModel(); IProjectValidator projectValidator = new ProjectValidator(); ICreateProjectCommand createProjectCommand = new CreateProjectCommand(dbContext, projectValidator); ProjectModel savedProject = createProjectCommand.Execute(project); Assert.Greater(savedProject.Id, 0); int rowCount = dbContext.ExecuteScalar <int>("SELECT COUNT(*) FROM Projects"); Assert.Greater(rowCount, 0); string projectName = dbContext.ExecuteScalar <string>("SELECT Name FROM projects WHERE Id = @Id", savedProject); Assert.AreEqual(savedProject.Name, projectName); } }