public void WrapFtpWebResponse_DisposeWithObject() { // https://stackoverflow.com/a/41961247 var ctor = typeof(FtpWebResponse).GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod).FirstOrDefault(); // using reflection // ReSharper disable once PossibleNullReferenceException var instance = (FtpWebResponse)ctor.Invoke(new object[] { new MemoryStream(), // Stream responseStream, 1L, // long contentLength, new Uri("ftp://google.com"), // Uri responseUri, FtpStatusCode.AccountNeeded, //FtpStatusCode statusCode, string.Empty, // string statusLine, DateTime.Now, // DateTime lastModified, string.Empty, // string bannerMessage, string.Empty, // string welcomeMessage string.Empty // string exitMessage }); var response = new WrapFtpWebResponse(instance); response.Dispose(); var responseStreamResult = response.GetResponseStream(); Assert.AreEqual(Stream.Null, responseStreamResult); }
public void GetResponseStream() { var responseStreamResult = new WrapFtpWebResponse(null).GetResponseStream(); Assert.AreEqual(Stream.Null, responseStreamResult); }