@@ -8,9 +8,10 @@ namespace LibGit2Sharp.Tests
88{
99 public class FilterFixture : BaseFixture
1010 {
11- private const int GitPassThrough = - 30 ;
12-
13- readonly Func < Stream , Stream , int > successCallback = ( reader , writer ) => 0 ;
11+ readonly Action < Stream , Stream > successCallback = ( reader , writer ) =>
12+ {
13+ reader . CopyTo ( writer ) ;
14+ } ;
1415
1516 private const string FilterName = "the-filter" ;
1617 readonly List < FilterAttributeEntry > attributes = new List < FilterAttributeEntry > { new FilterAttributeEntry ( "test" ) } ;
@@ -19,7 +20,7 @@ public class FilterFixture : BaseFixture
1920 public void CanRegisterFilterWithSingleAttribute ( )
2021 {
2122 var filter = new EmptyFilter ( FilterName , attributes ) ;
22- Assert . Equal ( attributes , filter . Attributes ) ;
23+ Assert . Equal ( attributes , filter . Attributes ) ;
2324 }
2425
2526 [ Fact ]
@@ -56,10 +57,9 @@ public void SameFilterIsEqual()
5657 public void InitCallbackNotMadeWhenFilterNeverUsed ( )
5758 {
5859 bool called = false ;
59- Func < int > initializeCallback = ( ) =>
60+ Action initializeCallback = ( ) =>
6061 {
6162 called = true ;
62- return 0 ;
6363 } ;
6464
6565 var filter = new FakeFilter ( FilterName + 11 , attributes ,
@@ -78,10 +78,9 @@ public void InitCallbackNotMadeWhenFilterNeverUsed()
7878 public void InitCallbackMadeWhenUsingTheFilter ( )
7979 {
8080 bool called = false ;
81- Func < int > initializeCallback = ( ) =>
81+ Action initializeCallback = ( ) =>
8282 {
8383 called = true ;
84- return 0 ;
8584 } ;
8685
8786 var filter = new FakeFilter ( FilterName + 12 , attributes ,
@@ -108,10 +107,10 @@ public void WhenStagingFileApplyIsCalledWithCleanForCorrectPath()
108107 string repoPath = InitNewRepository ( ) ;
109108 bool called = false ;
110109
111- Func < Stream , Stream , int > clean = ( reader , writer ) =>
110+ Action < Stream , Stream > clean = ( reader , writer ) =>
112111 {
113112 called = true ;
114- return GitPassThrough ;
113+ reader . CopyTo ( writer ) ;
115114 } ;
116115 var filter = new FakeFilter ( FilterName + 15 , attributes , clean ) ;
117116
@@ -134,7 +133,7 @@ public void CleanFilterWritesOutputToObjectTree()
134133
135134 string repoPath = InitNewRepository ( ) ;
136135
137- Func < Stream , Stream , int > cleanCallback = SubstitutionCipherFilter . RotateByThirteenPlaces ;
136+ Action < Stream , Stream > cleanCallback = SubstitutionCipherFilter . RotateByThirteenPlaces ;
138137
139138 var filter = new FakeFilter ( FilterName + 16 , attributes , cleanCallback ) ;
140139
@@ -154,7 +153,6 @@ public void CleanFilterWritesOutputToObjectTree()
154153 GlobalSettings . DeregisterFilter ( filterRegistration ) ;
155154 }
156155
157-
158156 [ Fact ]
159157 public void WhenCheckingOutAFileFileSmudgeWritesCorrectFileToWorkingDirectory ( )
160158 {
@@ -164,7 +162,7 @@ public void WhenCheckingOutAFileFileSmudgeWritesCorrectFileToWorkingDirectory()
164162 const string branchName = "branch" ;
165163 string repoPath = InitNewRepository ( ) ;
166164
167- Func < Stream , Stream , int > smudgeCallback = SubstitutionCipherFilter . RotateByThirteenPlaces ;
165+ Action < Stream , Stream > smudgeCallback = SubstitutionCipherFilter . RotateByThirteenPlaces ;
168166
169167 var filter = new FakeFilter ( FilterName + 17 , attributes , null , smudgeCallback ) ;
170168 var filterRegistration = GlobalSettings . RegisterFilter ( filter ) ;
@@ -237,34 +235,55 @@ public EmptyFilter(string name, IEnumerable<FilterAttributeEntry> attributes)
237235
238236 class FakeFilter : Filter
239237 {
240- private readonly Func < Stream , Stream , int > cleanCallback ;
241- private readonly Func < Stream , Stream , int > smudgeCallback ;
242- private readonly Func < int > initCallback ;
238+ private readonly Action < Stream , Stream > cleanCallback ;
239+ private readonly Action < Stream , Stream > smudgeCallback ;
240+ private readonly Action initCallback ;
243241
244242 public FakeFilter ( string name , IEnumerable < FilterAttributeEntry > attributes ,
245- Func < Stream , Stream , int > cleanCallback = null ,
246- Func < Stream , Stream , int > smudgeCallback = null ,
247- Func < int > initCallback = null )
243+ Action < Stream , Stream > cleanCallback = null ,
244+ Action < Stream , Stream > smudgeCallback = null ,
245+ Action initCallback = null )
248246 : base ( name , attributes )
249247 {
250248 this . cleanCallback = cleanCallback ;
251249 this . smudgeCallback = smudgeCallback ;
252250 this . initCallback = initCallback ;
253251 }
254252
255- protected override int Clean ( string path , Stream input , Stream output )
253+ protected override void Clean ( string path , string root , Stream input , Stream output )
256254 {
257- return cleanCallback != null ? cleanCallback ( input , output ) : base . Clean ( path , input , output ) ;
255+ if ( cleanCallback == null )
256+ {
257+ base . Clean ( path , root , input , output ) ;
258+ }
259+ else
260+ {
261+ cleanCallback ( input , output ) ;
262+ }
258263 }
259264
260- protected override int Smudge ( string path , Stream input , Stream output )
265+ protected override void Smudge ( string path , string root , Stream input , Stream output )
261266 {
262- return smudgeCallback != null ? smudgeCallback ( input , output ) : base . Smudge ( path , input , output ) ;
267+ if ( smudgeCallback == null )
268+ {
269+ base . Smudge ( path , root , input , output ) ;
270+ }
271+ else
272+ {
273+ smudgeCallback ( input , output ) ;
274+ }
263275 }
264276
265- protected override int Initialize ( )
277+ protected override void Initialize ( )
266278 {
267- return initCallback != null ? initCallback ( ) : base . Initialize ( ) ;
279+ if ( initCallback == null )
280+ {
281+ base . Initialize ( ) ;
282+ }
283+ else
284+ {
285+ initCallback ( ) ;
286+ }
268287 }
269288 }
270289 }
0 commit comments