System.Net.Tests.HttpRequestStreamTests.CanWrite_Get_ReturnsFalse [FAIL]
Assert.Throws() Failure
Expected: typeof(System.InvalidOperationException)
Actual: typeof(System.NotSupportedException): NotSupported_UnwritableStream. For more information, visit http://go.microsoft.com/fwlink/?Lin
kId=623485
Stack Trace:
at xunit.console.netcore!<BaseAddress>+0xa35f68
at System.Net.Tests.HttpRequestStreamTests.<>c__DisplayClass16_0.<CanWrite_Get_ReturnsFalse>b__1()
System.Net.Tests.HttpResponseStreamTests.CanRead_Get_ReturnsFalse [FAIL]
Assert.Throws() Failure
Expected: typeof(System.InvalidOperationException)
Actual: typeof(System.NotSupportedException): NotSupported_UnreadableStream. For more information, visit http://go.microsoft.com/fwlink/?Lin
kId=623485
Stack Trace:
at xunit.console.netcore!<BaseAddress>+0xb41398
at System.Net.Tests.HttpResponseStreamTests.<>c__DisplayClass12_0.<CanRead_Get_ReturnsFalse>b__1()
System.Net.Tests.HttpResponseStreamTests.Write_NullBuffer_ThrowsArgumentNullException [FAIL]
This is the implementation of the 3-parameter overload on
Stream
:It is not virtual and just calls the 4-parameter overload, which is virtual.
If you want to change the behavior of
ReadAsync
in a subclass ofStream
, all you need to do is override the 4-parameter overload. You should not add a new 3-parameter overload to the subclass.You can have the 3-parameter method call the 4-parameter method like this:
In other words, our code can call the 4-parameter one by passing in a None token if we don’t have one.