@@ -77,6 +77,28 @@ public void CustomSmartSubtransportTest(string scheme, string url)
7777 }
7878 }
7979
80+ [ Fact ]
81+ public void ExceptionPropogationTest ( )
82+ {
83+ var scd = BuildSelfCleaningDirectory ( ) ;
84+ var url = "https://github.com/libgit2/TestGitRepository" ;
85+
86+ SmartSubtransportRegistration < FailingSmartSubtransport > registration = null ;
87+
88+ try
89+ {
90+ registration = GlobalSettings . RegisterSmartSubtransport < FailingSmartSubtransport > ( "https" ) ;
91+ Assert . NotNull ( registration ) ;
92+
93+ var thrownException = Assert . Throws < LibGit2SharpException > ( ( ) => Repository . Clone ( url , scd . RootedDirectoryPath ) ) ;
94+ Assert . True ( thrownException . Message . Contains ( "This is a Read Exception" ) , "Exception message did not contain expected reference." ) ;
95+ }
96+ finally
97+ {
98+ GlobalSettings . UnregisterSmartSubtransport ( registration ) ;
99+ }
100+ }
101+
80102 //[Theory]
81103 //[InlineData("https", "https://bitbucket.org/libgit2/testgitrepository.git", "libgit3", "libgit3")]
82104 //public void CanUseCredentials(string scheme, string url, string user, string pass)
@@ -159,6 +181,32 @@ public void CannotUnregisterTwice()
159181 GlobalSettings . UnregisterSmartSubtransport ( httpRegistration ) ) ;
160182 }
161183
184+ private class FailingSmartSubtransport : RpcSmartSubtransport
185+ {
186+ protected override SmartSubtransportStream Action ( string url , GitSmartSubtransportAction action )
187+ {
188+ return new FailingSmartSubtransportStream ( this ) ;
189+ }
190+
191+ private class FailingSmartSubtransportStream : SmartSubtransportStream
192+ {
193+ public FailingSmartSubtransportStream ( FailingSmartSubtransport parent )
194+ : base ( parent )
195+ {
196+
197+ }
198+ public override int Read ( Stream dataStream , long length , out long bytesRead )
199+ {
200+ throw new Exception ( "This is a Read Exception" ) ;
201+ }
202+
203+ public override int Write ( Stream dataStream , long length )
204+ {
205+ throw new NotImplementedException ( ) ;
206+ }
207+ }
208+ }
209+
162210 private class MockSmartSubtransport : RpcSmartSubtransport
163211 {
164212 protected override SmartSubtransportStream Action ( string url , GitSmartSubtransportAction action )
0 commit comments