public void TestCompareListWithEqualsValues() { IDirectoryStructure directoryStructure = new ListWithEqualValues(); using (var compareDirectoryStructure = new CompareDirectoryStructure(directoryStructure)) { Assert.IsTrue(compareDirectoryStructure.ActionList.Count == 0); } }
public void CompareResultWrongActionList() { var lstDirectoryStructure = new ListWithDiffValues(); using (var compareDirectoryStructure = new CompareDirectoryStructure(lstDirectoryStructure)) { var items = lstDirectoryStructure.GetFakeClassWrongActionList(); Assert.IsFalse(compareDirectoryStructure.ActionList.Join(items, row1 => row1.DirectoryItemValue.Name, row2 => row2.DirectoryItemValue.Name, (row1, row2) => new { row1.DirectoryItemValue }).ToList().Count() == 2); } }
public void CompareListWithDiffValues() { var lstDirectoryStructure = new ListWithDiffValues(); using (var compareDirectoryStructure = new CompareDirectoryStructure(lstDirectoryStructure)) { Assert.IsTrue(compareDirectoryStructure.ActionList.Count == 2); var items = lstDirectoryStructure.GetDirectoriesContent(); Assert.IsTrue(compareDirectoryStructure.CompareResult.Join(items, row1 => row1.ComparableValue, row2 => row2.ComparableValue, (row1, row2) => new { row1.ComparableValue }).ToList().Count() == 2); } }
/// <summary> /// Start compare directories /// </summary> public void StartCompareDirectoryCommand() { try { //Clear last messages SystemInfoMessage = new InfoMessage() { Visible = false }; //Clear child items this.DirectoryAndActionItems = null; this.Items = null; // Get the all directories and files from first and second Path using (var compareDirectoryStructure = new CompareDirectoryStructure(new DirectoryStructure(FirstDirectory, SecondDirectory))) { var children = compareDirectoryStructure.CompareResult; // Create the view models from the data this.Items = new ObservableCollection <CompareDirectoryItemVM>( children.Select(value => new CompareDirectoryItemVM(value))); //Check Action list items count if (compareDirectoryStructure.ActionList.Count() > 0) { this.DirectoryAndActionItems = new ObservableCollection <DirectoryItemAndActionVM>( compareDirectoryStructure.ActionList.Select(value => new DirectoryItemAndActionVM( value.DirectoryItemValue.FullPath, value.DirectoryItemValue.Name, value.ActionType))); } else { //Show information when Action list is empty SystemInfoMessage = new InfoMessage() { Visible = true, BackgroundColor = SystemConstant.InfoColor, Message = Messages.DirectoriesstructureAreSame }; } } //Set property change "Items" OnPropertyChanged("Items"); //Set property cnage "DirectoryAndActionItems" OnPropertyChanged("DirectoryAndActionItems"); } catch (CustomException customException) { //Show Detail information about exception SystemInfoMessage = new InfoMessage() { Visible = true, BackgroundColor = SystemConstant.ErrorColor, Message = customException.Message }; } catch (Exception ex) { //Show Detail information about exception SystemInfoMessage = new InfoMessage() { Visible = true, BackgroundColor = SystemConstant.ErrorColor, Message = String.Format(Messages.ErrorDetailDetails, ex.Message) }; } }