public void CopyToFile_NonWindows_CallsFileStreamCopy()
 {
     using (var directory = TestDirectory.Create())
     {
         var testPath = Path.Combine(directory, Path.GetRandomFileName());
         var environmentVariableReader = new Mock <IEnvironmentVariableReader>();
         var uut = new TestableProxy(environmentVariableReader.Object);
         uut.CopyToFile(new MemoryStream(Encoding.UTF8.GetBytes(TestText)), testPath);
         Assert.False(uut.MmapCopyWasCalled);
         Assert.True(uut.FileStreamCopyWasCalled);
         Assert.Equal(TestText, File.ReadAllText(testPath));
     }
 }
 public void CopyToFile_EnvironmentVariable_IsRespected(string env, bool expectedMMap)
 {
     using (var directory = TestDirectory.Create())
     {
         var environmentVariableReader = new Mock <IEnvironmentVariableReader>();
         environmentVariableReader.Setup(x => x.GetEnvironmentVariable("NUGET_PACKAGE_EXTRACTION_USE_MMAP"))
         .Returns(env);
         var uut      = new TestableProxy(environmentVariableReader.Object);
         var testPath = Path.Combine(directory, Path.GetRandomFileName());
         uut.CopyToFile(new MemoryStream(Encoding.UTF8.GetBytes(TestText)), testPath);
         Assert.Equal(uut.MmapCopyWasCalled, expectedMMap);
         Assert.Equal(uut.FileStreamCopyWasCalled, !uut.MmapCopyWasCalled);
         Assert.Equal(TestText, File.ReadAllText(testPath));
     }
 }