@@ -63,7 +63,7 @@ public void CanEnumeratorStagedFiles()
63
63
}
64
64
65
65
[ Test ]
66
- public void CanReadIndexEntry ( )
66
+ public void CanFetchAnIndexEntryByItsName ( )
67
67
{
68
68
using ( var repo = new Repository ( Constants . StandardTestRepoPath ) )
69
69
{
@@ -99,6 +99,7 @@ public void CanStageANewFile()
99
99
{
100
100
var count = repo . Index . Count ;
101
101
const string filename = "unit_test.txt" ;
102
+ repo . Index [ filename ] . ShouldBeNull ( ) ;
102
103
File . WriteAllText ( Path . Combine ( repo . Info . WorkingDirectory , filename ) , "some contents" ) ;
103
104
104
105
repo . Index . Stage ( filename ) ;
@@ -108,6 +109,43 @@ public void CanStageANewFile()
108
109
}
109
110
}
110
111
112
+ [ Test ]
113
+ public void StagingANewVersionOfAFileThenUnstagingRevertsTheBlobToTheVersionOfHead ( )
114
+ {
115
+ using ( var scd = new SelfCleaningDirectory ( ) )
116
+ {
117
+ string dir = Repository . Init ( scd . DirectoryPath ) ;
118
+
119
+ using ( var repo = new Repository ( dir ) )
120
+ {
121
+ repo . Index . Count . ShouldEqual ( 0 ) ;
122
+
123
+ const string fileName = "myFile.txt" ;
124
+
125
+ var fullpath = Path . Combine ( repo . Info . WorkingDirectory , fileName ) ;
126
+
127
+ const string initialContent = "Hello?" ;
128
+ File . AppendAllText ( fullpath , initialContent ) ;
129
+
130
+ repo . Index . Stage ( fileName ) ;
131
+ var blobId = repo . Index [ fileName ] . Id ;
132
+
133
+ repo . Commit ( Constants . Signature , Constants . Signature , "Initial commit" ) ;
134
+ repo . Index . Count . ShouldEqual ( 1 ) ;
135
+
136
+ File . AppendAllText ( fullpath , "Is there there anybody out there?" ) ;
137
+ repo . Index . Stage ( fileName ) ;
138
+
139
+ repo . Index . Count . ShouldEqual ( 1 ) ;
140
+ repo . Index [ fileName ] . Id . ShouldNotEqual ( ( blobId ) ) ;
141
+
142
+ repo . Index . Unstage ( fileName ) ;
143
+ repo . Index . Count . ShouldEqual ( 1 ) ;
144
+ repo . Index [ fileName ] . Id . ShouldEqual ( ( blobId ) ) ;
145
+ }
146
+ }
147
+ }
148
+
111
149
[ Test ]
112
150
public void CanStageANewFileInAPersistentManner ( )
113
151
{
0 commit comments