@@ -39,7 +39,7 @@ public void RetrievingANonExistentFileChangeReturnsNull()
39
39
40
40
var changes = repo . Diff . Compare < TreeChanges > ( tree , tree ) ;
41
41
42
- Assert . Null ( changes [ "batman" ] ) ;
42
+ Assert . Equal ( 0 , changes . Count ( c => c . Path == "batman" ) ) ;
43
43
}
44
44
}
45
45
@@ -62,7 +62,7 @@ public void CanCompareACommitTreeAgainstItsParent()
62
62
Assert . Equal ( 1 , changes . Count ( ) ) ;
63
63
Assert . Equal ( 1 , changes . Added . Count ( ) ) ;
64
64
65
- TreeEntryChanges treeEntryChanges = changes [ "1.txt" ] ;
65
+ TreeEntryChanges treeEntryChanges = changes . Single ( c => c . Path == "1.txt" ) ;
66
66
67
67
var patch = repo . Diff . Compare < Patch > ( parentCommitTree , commitTree ) ;
68
68
Assert . False ( patch [ "1.txt" ] . IsBinaryComparison ) ;
@@ -272,8 +272,7 @@ public void DetectsTheRenamingOfAModifiedFileByDefault()
272
272
var changes = repo . Diff . Compare < TreeChanges > ( rootCommitTree , commitTreeWithRenamedFile ) ;
273
273
274
274
Assert . Equal ( 1 , changes . Count ( ) ) ;
275
- Assert . Equal ( "super-file.txt" , changes [ "super-file.txt" ] . Path ) ;
276
- Assert . Equal ( "my-name-does-not-feel-right.txt" , changes [ "super-file.txt" ] . OldPath ) ;
275
+ Assert . Equal ( "my-name-does-not-feel-right.txt" , changes . Single ( c => c . Path == "super-file.txt" ) . OldPath ) ;
277
276
Assert . Equal ( 1 , changes . Renamed . Count ( ) ) ;
278
277
}
279
278
}
@@ -888,7 +887,7 @@ public void CanCompareTwoVersionsOfAFileWithADiffOfTwoHunks(int contextLines, in
888
887
Assert . Equal ( 1 , changes . Deleted . Count ( ) ) ;
889
888
Assert . Equal ( 1 , changes . Added . Count ( ) ) ;
890
889
891
- Assert . Equal ( Mode . Nonexistent , changes [ "my-name-does-not-feel-right.txt" ] . Mode ) ;
890
+ Assert . Equal ( Mode . Nonexistent , changes . Single ( c => c . Path == "my-name-does-not-feel-right.txt" ) . Mode ) ;
892
891
893
892
var patch = repo . Diff . Compare < Patch > ( rootCommitTree , mergedCommitTree , compareOptions : compareOptions ) ;
894
893
@@ -904,14 +903,13 @@ public void CanCompareTwoVersionsOfAFileWithADiffOfTwoHunks(int contextLines, in
904
903
}
905
904
}
906
905
907
- [ Fact ]
908
- public void CanHandleTwoTreeEntryChangesWithTheSamePath ( )
906
+ private void CanHandleTwoTreeEntryChangesWithTheSamePath ( SimilarityOptions similarity , Action < string , TreeChanges > verifier )
909
907
{
910
908
string repoPath = InitNewRepository ( ) ;
911
909
912
910
using ( var repo = new Repository ( repoPath ) )
913
911
{
914
- Blob mainContent = OdbHelper . CreateBlob ( repo , "awesome content\n " ) ;
912
+ Blob mainContent = OdbHelper . CreateBlob ( repo , "awesome content\n " + new string ( 'b' , 4096 ) ) ;
915
913
Blob linkContent = OdbHelper . CreateBlob ( repo , "../../objc/Nu.h" ) ;
916
914
917
915
string path = string . Format ( "include{0}Nu{0}Nu.h" , Path . DirectorySeparatorChar ) ;
@@ -930,45 +928,68 @@ public void CanHandleTwoTreeEntryChangesWithTheSamePath()
930
928
var changes = repo . Diff . Compare < TreeChanges > ( treeOld , treeNew ,
931
929
compareOptions : new CompareOptions
932
930
{
933
- Similarity = SimilarityOptions . None ,
931
+ Similarity = similarity ,
934
932
} ) ;
933
+ }
934
+ }
935
935
936
- /*
937
- * $ git diff-tree -p 5c87b67 d5278d0
938
- * diff --git a/include/Nu/Nu.h b/include/Nu/Nu.h
939
- * deleted file mode 120000
940
- * index 19bf568..0000000
941
- * --- a/include/Nu/Nu.h
942
- * +++ /dev/null
943
- * @@ -1 +0,0 @@
944
- * -../../objc/Nu.h
945
- * \ No newline at end of file
946
- * diff --git a/include/Nu/Nu.h b/include/Nu/Nu.h
947
- * new file mode 100644
948
- * index 0000000..f9e6561
949
- * --- /dev/null
950
- * +++ b/include/Nu/Nu.h
951
- * @@ -0,0 +1 @@
952
- * +awesome content
953
- * diff --git a/objc/Nu.h b/objc/Nu.h
954
- * deleted file mode 100644
955
- * index f9e6561..0000000
956
- * --- a/objc/Nu.h
957
- * +++ /dev/null
958
- * @@ -1 +0,0 @@
959
- * -awesome content
960
- */
936
+ [ Fact ]
937
+ public void CanHandleTwoTreeEntryChangesWithTheSamePathUsingSimilarityNone ( )
938
+ {
939
+ /*
940
+ * $ git diff-tree -p 5c87b67 d5278d0
941
+ * diff --git a/include/Nu/Nu.h b/include/Nu/Nu.h
942
+ * deleted file mode 120000
943
+ * index 19bf568..0000000
944
+ * --- a/include/Nu/Nu.h
945
+ * +++ /dev/null
946
+ * @@ -1 +0,0 @@
947
+ * -../../objc/Nu.h
948
+ * \ No newline at end of file
949
+ * diff --git a/include/Nu/Nu.h b/include/Nu/Nu.h
950
+ * new file mode 100644
951
+ * index 0000000..f9e6561
952
+ * --- /dev/null
953
+ * +++ b/include/Nu/Nu.h
954
+ * @@ -0,0 +1 @@
955
+ * +awesome content
956
+ * diff --git a/objc/Nu.h b/objc/Nu.h
957
+ * deleted file mode 100644
958
+ * index f9e6561..0000000
959
+ * --- a/objc/Nu.h
960
+ * +++ /dev/null
961
+ * @@ -1 +0,0 @@
962
+ * -awesome content
963
+ */
964
+
965
+ CanHandleTwoTreeEntryChangesWithTheSamePath ( SimilarityOptions . None ,
966
+ ( path , changes ) =>
967
+ {
968
+ Assert . Equal ( 1 , changes . Deleted . Count ( ) ) ;
969
+ Assert . Equal ( 0 , changes . Modified . Count ( ) ) ;
970
+ Assert . Equal ( 1 , changes . TypeChanged . Count ( ) ) ;
971
+
972
+ TreeEntryChanges change = changes . Single ( c => c . Path == path ) ;
973
+ Assert . Equal ( Mode . SymbolicLink , change . OldMode ) ;
974
+ Assert . Equal ( Mode . NonExecutableFile , change . Mode ) ;
975
+ Assert . Equal ( ChangeKind . TypeChanged , change . Status ) ;
976
+ Assert . Equal ( path , change . Path ) ;
977
+ } ) ;
978
+ }
961
979
962
- Assert . Equal ( 1 , changes . Deleted . Count ( ) ) ;
963
- Assert . Equal ( 0 , changes . Modified . Count ( ) ) ;
964
- Assert . Equal ( 1 , changes . TypeChanged . Count ( ) ) ;
980
+ [ Fact ]
981
+ public void CanHandleTwoTreeEntryChangesWithTheSamePathUsingSimilarityDefault ( )
982
+ {
983
+ /*
984
+ * $ git diff-tree -p 5c87b67 d5278d0
985
+ * To be done...
986
+ */
965
987
966
- TreeEntryChanges change = changes [ path ] ;
967
- Assert . Equal ( Mode . SymbolicLink , change . OldMode ) ;
968
- Assert . Equal ( Mode . NonExecutableFile , change . Mode ) ;
969
- Assert . Equal ( ChangeKind . TypeChanged , change . Status ) ;
970
- Assert . Equal ( path , change . Path ) ;
971
- }
988
+ CanHandleTwoTreeEntryChangesWithTheSamePath ( SimilarityOptions . Default ,
989
+ ( path , changes ) =>
990
+ {
991
+ // TODO: What should we assert there?
992
+ } ) ;
972
993
}
973
994
974
995
[ Fact ]
@@ -1104,8 +1125,8 @@ public void RetrievingDiffChangesMustAlwaysBeCaseSensitive()
1104
1125
{
1105
1126
var changes = repo . Diff . Compare < TreeChanges > ( repo . Lookup < Tree > ( treeOldOid ) , repo . Lookup < Tree > ( treeNewOid ) ) ;
1106
1127
1107
- Assert . Equal ( ChangeKind . Modified , changes [ "a.txt" ] . Status ) ;
1108
- Assert . Equal ( ChangeKind . Modified , changes [ "A.TXT" ] . Status ) ;
1128
+ Assert . Equal ( ChangeKind . Modified , changes . Single ( c => c . Path == "a.txt" ) . Status ) ;
1129
+ Assert . Equal ( ChangeKind . Modified , changes . Single ( c => c . Path == "A.TXT" ) . Status ) ;
1109
1130
}
1110
1131
}
1111
1132
0 commit comments