public PerFileModification Classify(InfoPair pair) { EFileModification modification; var result = new PerFileModification() { Filename = pair.FileName }; if (pair.OldFileHash == null) { modification = EFileModification.Added; } else if (pair.NewFileHash == null) { modification = EFileModification.Removed; } else if (pair.NewFileHash.Equals(pair.OldFileHash)) { modification = EFileModification.NoChange; } else { modification = EFileModification.Modified; } result.Modification = modification; return(result); }
public void ClassifyNoOldFileShouldReturnAddedTest() { var mc = new ModificationClassificator(); var input = new InfoPair() { NewFileHash = "asdf", OldFileHash = null }; var result = mc.Classify(input); Assert.IsTrue(result.Modification == EFileModification.Added); }
public void ClassifyBothFilesAndSameHashShouldReturnNoChange() { var mc = new ModificationClassificator(); const string sameHash = "asdf"; var input = new InfoPair() { NewFileHash = sameHash, OldFileHash = sameHash }; var result = mc.Classify(input); Assert.IsTrue(result.Modification == EFileModification.NoChange); }
public void ClassifyBothFilesAndDifferentHashShouldReturnNoChange() { var mc = new ModificationClassificator(); const string hash = "asdf"; const string differentHash = "fdsa"; var input = new InfoPair() { NewFileHash = hash, OldFileHash = differentHash }; var result = mc.Classify(input); Assert.IsTrue(result.Modification == EFileModification.Modified); }
private List<InfoPair> CreateInfoPairs( String value ) { List<InfoPair> list = new List<InfoPair>(); foreach ( String chanLimitPair in value.Split( ',' ) ) { if ( chanLimitPair.Contains( ":" ) ) { String[] chanLimitInfo = chanLimitPair.Split( ':' ); if ( chanLimitInfo.Length == 2 && chanLimitInfo[0].Length > 0 ) { InfoPair pair = new InfoPair( chanLimitInfo[0], chanLimitInfo[1] ); list.Add( pair ); } } } return list; }