You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.88
Former-commit-id: 4b7216ffda08448e562271ce733688e761120fc5
This commit is contained in:
parent
7d05485754
commit
6123a772ed
@@ -34,7 +34,7 @@ static class Consts
|
||||
// Use these assembly version constants to make code more maintainable.
|
||||
//
|
||||
|
||||
public const string MonoVersion = "5.8.0.22";
|
||||
public const string MonoVersion = "5.8.0.88";
|
||||
public const string MonoCompany = "Mono development team";
|
||||
public const string MonoProduct = "Mono Common Language Infrastructure";
|
||||
public const string MonoCopyright = "(c) Various Mono authors";
|
||||
|
@@ -26,6 +26,7 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if !FULL_AOT_RUNTIME
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Mono.CSharp;
|
||||
@@ -75,4 +76,5 @@ namespace MonoTests.EvaluatorTest
|
||||
Assert.IsNull (res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -25,7 +25,7 @@
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if !FULL_AOT_RUNTIME
|
||||
using NUnit.Framework;
|
||||
using Mono.CSharp;
|
||||
|
||||
@@ -41,4 +41,5 @@ namespace MonoTests.EvaluatorTest
|
||||
evaluator2.Run ("int i = 0;");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -25,7 +25,7 @@
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if !FULL_AOT_RUNTIME
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Mono.CSharp;
|
||||
@@ -203,3 +203,4 @@ namespace MonoTests.EvaluatorTest
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -25,7 +25,7 @@
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if !FULL_AOT_RUNTIME
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Mono.CSharp;
|
||||
@@ -132,4 +132,5 @@ namespace MonoTests.EvaluatorTest
|
||||
Evaluator.Run ("public class TestClass { private TestEnum _te; public string Get() { return _te.ToString(); } } public enum TestEnum { First, Second }");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -20,13 +20,24 @@ namespace MonoTests.Mono.Data.Sqlite {
|
||||
|
||||
[TestFixture]
|
||||
public class SqliteiOS82BugTests {
|
||||
readonly static string dbPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "adodemo.db3");
|
||||
readonly static string connectionString = "Data Source=" + dbPath;
|
||||
static SqliteConnection cnn = new SqliteConnection (connectionString);
|
||||
string dbPath;
|
||||
string connectionString;
|
||||
SqliteConnection cnn;
|
||||
|
||||
[SetUp]
|
||||
public void Create()
|
||||
{
|
||||
dbPath = Path.GetTempFileName ();
|
||||
|
||||
// We want to start with a fresh db for each full run
|
||||
// The database is created on the first open()
|
||||
// but TempFile does create a file
|
||||
if (File.Exists (dbPath))
|
||||
File.Delete (dbPath);
|
||||
|
||||
connectionString = "Data Source=" + dbPath;
|
||||
cnn = new SqliteConnection (connectionString);
|
||||
|
||||
try {
|
||||
if(File.Exists(dbPath)) {
|
||||
cnn.Dispose();
|
||||
@@ -56,6 +67,13 @@ namespace MonoTests.Mono.Data.Sqlite {
|
||||
}
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown ()
|
||||
{
|
||||
if (File.Exists (dbPath))
|
||||
File.Delete (dbPath);
|
||||
}
|
||||
|
||||
// Ref: https://bugzilla.xamarin.com/show_bug.cgi?id=27864
|
||||
// As of iOS 8.2 Apple updated Sqlite and broke queries that used to work pre iOS 8.2 like the select command in this test
|
||||
// The pruppose of this test is to know when apple fixes this. Expected test behaivour is as follows.
|
||||
|
@@ -16,9 +16,9 @@ namespace MonoTests.Mono.Data.Sqlite
|
||||
[TestFixture]
|
||||
public class SqliteCommandUnitTests
|
||||
{
|
||||
readonly static string _uri = Path.Combine (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SqliteTest.db");
|
||||
readonly static string _connectionString = "URI=file://" + _uri + ", version=3";
|
||||
static SqliteConnection _conn = new SqliteConnection (_connectionString);
|
||||
string _uri;
|
||||
string _connectionString;
|
||||
SqliteConnection _conn;
|
||||
readonly static string stringvalue = "my keyboard is better than yours : äöüß";
|
||||
|
||||
public SqliteCommandUnitTests()
|
||||
@@ -28,6 +28,10 @@ namespace MonoTests.Mono.Data.Sqlite
|
||||
[SetUp]
|
||||
public void Create()
|
||||
{
|
||||
_uri = Path.GetTempFileName ();
|
||||
_connectionString = "URI=file://" + _uri + ", version=3";
|
||||
_conn = new SqliteConnection (_connectionString);
|
||||
|
||||
try
|
||||
{
|
||||
if(File.Exists(_uri))
|
||||
@@ -65,6 +69,13 @@ namespace MonoTests.Mono.Data.Sqlite
|
||||
}
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown ()
|
||||
{
|
||||
if (File.Exists (_uri))
|
||||
File.Delete (_uri);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Select()
|
||||
{
|
||||
@@ -195,4 +206,4 @@ namespace MonoTests.Mono.Data.Sqlite
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,13 +37,33 @@ using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.Mono.Data.Sqlite
|
||||
{
|
||||
[TestFixture]
|
||||
public class SqliteConnectionTest
|
||||
{
|
||||
readonly static string _uri = Path.Combine (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "test.db");
|
||||
readonly static string _connectionString = "URI=file://" + _uri + ", version=3";
|
||||
SqliteConnection _conn = new SqliteConnection ();
|
||||
[TestFixture]
|
||||
public class SqliteConnectionTest
|
||||
{
|
||||
string _dataFolder;
|
||||
string _uri;
|
||||
string _connectionString;
|
||||
SqliteConnection _conn;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp ()
|
||||
{
|
||||
_dataFolder = Path.GetTempFileName ();
|
||||
if (File.Exists (_dataFolder))
|
||||
File.Delete (_dataFolder);
|
||||
Directory.CreateDirectory (_dataFolder);
|
||||
|
||||
_uri = Path.Combine (_dataFolder, "test.db");
|
||||
_connectionString = "URI=file://" + _uri + ", version=3";
|
||||
_conn = new SqliteConnection ();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TeatDown ()
|
||||
{
|
||||
if (Directory.Exists (_dataFolder))
|
||||
Directory.Delete (_dataFolder, true);
|
||||
}
|
||||
[Test]
|
||||
public void ReleaseDatabaseFileHandles ()
|
||||
{
|
||||
@@ -64,49 +84,49 @@ namespace MonoTests.Mono.Data.Sqlite
|
||||
File.Delete (_uri);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
public void ConnectionStringTest_Null ()
|
||||
{
|
||||
_conn.ConnectionString = null;
|
||||
}
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
public void ConnectionStringTest_Null ()
|
||||
{
|
||||
_conn.ConnectionString = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (InvalidOperationException))]
|
||||
public void ConnectionStringTest_MustBeClosed ()
|
||||
{
|
||||
_conn.ConnectionString = _connectionString;
|
||||
try {
|
||||
_conn.Open ();
|
||||
_conn.ConnectionString = _connectionString;
|
||||
} finally {
|
||||
_conn.Close ();
|
||||
}
|
||||
}
|
||||
[Test]
|
||||
[ExpectedException (typeof (InvalidOperationException))]
|
||||
public void ConnectionStringTest_MustBeClosed ()
|
||||
{
|
||||
_conn.ConnectionString = _connectionString;
|
||||
try {
|
||||
_conn.Open ();
|
||||
_conn.ConnectionString = _connectionString;
|
||||
} finally {
|
||||
_conn.Close ();
|
||||
}
|
||||
}
|
||||
|
||||
// behavior has changed, I guess
|
||||
//[Test]
|
||||
[Ignore ("opening a connection should not create db! though, leave for now")]
|
||||
public void OpenTest ()
|
||||
{
|
||||
try {
|
||||
_conn.ConnectionString = _connectionString;
|
||||
_conn.Open ();
|
||||
Assert.AreEqual (ConnectionState.Open, _conn.State, "#1 not opened");
|
||||
_conn.Close ();
|
||||
// behavior has changed, I guess
|
||||
//[Test]
|
||||
[Ignore ("opening a connection should not create db! though, leave for now")]
|
||||
public void OpenTest ()
|
||||
{
|
||||
try {
|
||||
_conn.ConnectionString = _connectionString;
|
||||
_conn.Open ();
|
||||
Assert.AreEqual (ConnectionState.Open, _conn.State, "#1 not opened");
|
||||
_conn.Close ();
|
||||
|
||||
// negative test: try opening a non-existent file
|
||||
_conn.ConnectionString = "URI=file://abcdefgh.db, version=3";
|
||||
try {
|
||||
_conn.Open ();
|
||||
Assert.Fail ("#1 should have failed on opening a non-existent db");
|
||||
} catch (ArgumentException e) {Console.WriteLine (e);}
|
||||
|
||||
} finally {
|
||||
if (_conn != null && _conn.State != ConnectionState.Closed)
|
||||
_conn.Close ();
|
||||
}
|
||||
}
|
||||
// negative test: try opening a non-existent file
|
||||
_conn.ConnectionString = "URI=file://abcdefgh.db, version=3";
|
||||
try {
|
||||
_conn.Open ();
|
||||
Assert.Fail ("#1 should have failed on opening a non-existent db");
|
||||
} catch (ArgumentException e) {Console.WriteLine (e);}
|
||||
|
||||
} finally {
|
||||
if (_conn != null && _conn.State != ConnectionState.Closed)
|
||||
_conn.Close ();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,11 +15,26 @@ namespace MonoTests.Mono.Data.Sqlite
|
||||
[TestFixture]
|
||||
public class SqliteDataAdapterUnitTests
|
||||
{
|
||||
readonly static string _uri = "SqliteTest.db";
|
||||
readonly static string _connectionString = "URI=file://" + _uri + ", version=3";
|
||||
static SqliteConnection _conn = new SqliteConnection (_connectionString);
|
||||
string _uri;
|
||||
string _connectionString;
|
||||
SqliteConnection _conn;
|
||||
|
||||
static SqliteDataAdapter PrepareDataAdapter()
|
||||
[SetUp]
|
||||
public void SetUp ()
|
||||
{
|
||||
_uri = Path.GetTempFileName ();
|
||||
_connectionString = "URI=file://" + _uri + ", version=3";
|
||||
_conn = new SqliteConnection (_connectionString);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown ()
|
||||
{
|
||||
if (File.Exists (_uri))
|
||||
File.Delete (_uri);
|
||||
}
|
||||
|
||||
SqliteDataAdapter PrepareDataAdapter()
|
||||
{
|
||||
SqliteCommand select = new SqliteCommand("SELECT t, f, i, b FROM t1",_conn);
|
||||
SqliteCommand update = new SqliteCommand("UPDATE t1 SET t = :textP, f = :floatP, i = :integerP, n=:blobP WHERE t = :textP ");
|
||||
|
@@ -15,12 +15,23 @@ namespace MonoTests.Mono.Data.Sqlite
|
||||
[TestFixture]
|
||||
public class SqliteExceptionUnitTests
|
||||
{
|
||||
readonly static string _uri = "SqliteTest.db";
|
||||
readonly static string _connectionString = "URI=file://" + _uri + ", version=3";
|
||||
static SqliteConnection _conn = new SqliteConnection (_connectionString);
|
||||
static string _uri;
|
||||
static string _connectionString;
|
||||
SqliteConnection _conn;
|
||||
|
||||
public SqliteExceptionUnitTests()
|
||||
[SetUp]
|
||||
public void SetUp ()
|
||||
{
|
||||
_uri = Path.GetTempFileName ();
|
||||
_connectionString = "URI=file://" + _uri + ", version=3";
|
||||
_conn = new SqliteConnection (_connectionString);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown ()
|
||||
{
|
||||
if (File.Exists (_uri))
|
||||
File.Delete (_uri);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@@ -20,7 +20,20 @@ namespace MonoTests.Mono.Data.Sqlite
|
||||
[TestFixture]
|
||||
public class SqliteFunctionTest
|
||||
{
|
||||
readonly static string uri = Path.Combine (Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "test.db");
|
||||
string uri;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp ()
|
||||
{
|
||||
uri = Path.GetTempFileName ();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown ()
|
||||
{
|
||||
if (File.Exists (uri))
|
||||
File.Delete (uri);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CollationTest()
|
||||
|
@@ -15,14 +15,24 @@ namespace MonoTests.Mono.Data.Sqlite
|
||||
[TestFixture]
|
||||
public class SqliteParameterUnitTests
|
||||
{
|
||||
readonly static string _uri = "SqliteTest.db";
|
||||
readonly static string _connectionString = "URI=file://" + _uri + ", version=3";
|
||||
static SqliteConnection _conn = new SqliteConnection (_connectionString);
|
||||
string _uri;
|
||||
string _connectionString;
|
||||
SqliteConnection _conn;
|
||||
|
||||
public SqliteParameterUnitTests()
|
||||
[SetUp]
|
||||
public void SetUp ()
|
||||
{
|
||||
_uri = Path.GetTempFileName ();
|
||||
_connectionString = "URI=file://" + _uri + ", version=3";
|
||||
_conn = new SqliteConnection (_connectionString);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown ()
|
||||
{
|
||||
if (File.Exists (_uri))
|
||||
File.Delete (_uri);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
// fails randomly :)
|
||||
|
@@ -43,24 +43,16 @@ namespace MonoTests.Mono.Data.Sqlite
|
||||
[SetUp]
|
||||
public void Setup ()
|
||||
{
|
||||
var dataFolder = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "SqlTest");
|
||||
|
||||
_databasePath = Path.Combine (dataFolder, "database.db");
|
||||
|
||||
if (!Directory.Exists (dataFolder)) {
|
||||
Directory.CreateDirectory (dataFolder);
|
||||
}
|
||||
|
||||
_databasePath = Path.GetTempFileName ();
|
||||
File.Delete (_databasePath);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown ()
|
||||
{
|
||||
try {
|
||||
if (File.Exists (_databasePath))
|
||||
File.Delete (_databasePath);
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@@ -176,6 +176,9 @@ namespace MonoTests.Mono.Unix.Native
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if MONODROID
|
||||
[ExpectedException (typeof (ArgumentOutOfRangeException))] // IPPROTO_TCP not supported
|
||||
#endif
|
||||
public void SockOptLinger ()
|
||||
{
|
||||
WithSockets (UnixAddressFamily.AF_INET, UnixSocketType.SOCK_STREAM, UnixSocketProtocol.IPPROTO_TCP, (so1, so2) => {
|
||||
@@ -347,6 +350,9 @@ namespace MonoTests.Mono.Unix.Native
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if MONODROID
|
||||
[ExpectedException (typeof (ArgumentOutOfRangeException))] // IPPROTO_UDP not supported
|
||||
#endif
|
||||
public void BindConnect ()
|
||||
{
|
||||
WithSockets (UnixAddressFamily.AF_INET, UnixSocketType.SOCK_DGRAM, UnixSocketProtocol.IPPROTO_UDP, (so1, so2) => {
|
||||
@@ -516,6 +522,9 @@ namespace MonoTests.Mono.Unix.Native
|
||||
|
||||
[Test]
|
||||
[Category ("NotOnMac")]
|
||||
#if MONODROID
|
||||
[ExpectedException (typeof (ArgumentOutOfRangeException))] // SOCK_NONBLOCK, SOCK_CLOEXEC not supported
|
||||
#endif
|
||||
public void Accept4 ()
|
||||
{
|
||||
WithSockets (UnixAddressFamily.AF_UNIX, UnixSocketType.SOCK_STREAM, 0, (so1, so2) => {
|
||||
@@ -553,6 +562,9 @@ namespace MonoTests.Mono.Unix.Native
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if MONODROID
|
||||
[ExpectedException (typeof (ArgumentOutOfRangeException))] // IPPROTO_UDP not supported
|
||||
#endif
|
||||
public void SendToRecvFrom ()
|
||||
{
|
||||
WithSockets (UnixAddressFamily.AF_INET, UnixSocketType.SOCK_DGRAM, UnixSocketProtocol.IPPROTO_UDP, (so1, so2) => {
|
||||
@@ -643,6 +655,9 @@ namespace MonoTests.Mono.Unix.Native
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if MONODROID
|
||||
[ExpectedException (typeof (ArgumentOutOfRangeException))] // IPPROTO_UDP not supported
|
||||
#endif
|
||||
public unsafe void SendMsgRecvMsgAddress ()
|
||||
{
|
||||
WithSockets (UnixAddressFamily.AF_INET, UnixSocketType.SOCK_DGRAM, UnixSocketProtocol.IPPROTO_UDP, (so1, so2) => {
|
||||
|
@@ -37,7 +37,7 @@ namespace MonoTests.System.Security.Cryptography {
|
||||
public class AesManagedTest {
|
||||
|
||||
[Test]
|
||||
#if !MONOTOUCH
|
||||
#if !MONOTOUCH && !XAMMAC
|
||||
[ExpectedException (typeof (CryptographicException))]
|
||||
#endif
|
||||
public void CFB_NotAllowed ()
|
||||
@@ -61,7 +61,7 @@ namespace MonoTests.System.Security.Cryptography {
|
||||
}
|
||||
|
||||
[Test]
|
||||
#if !MONOTOUCH
|
||||
#if !MONOTOUCH && !XAMMAC
|
||||
[ExpectedException (typeof (CryptographicException))]
|
||||
#endif
|
||||
public void OFB_NotAllowed ()
|
||||
|
@@ -36,22 +36,29 @@ namespace MonoTests.System.IO.Compression.FileSystem
|
||||
[TestFixture]
|
||||
public class ZipArchiveTests
|
||||
{
|
||||
string tmpFile;
|
||||
[SetUp]
|
||||
public void SetUp ()
|
||||
{
|
||||
tmpFile = Path.GetTempFileName ();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Dispose()
|
||||
{
|
||||
File.Delete ("foo.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipCreateFromDirectory()
|
||||
{
|
||||
if (File.Exists ("foo.zip"))
|
||||
File.Delete ("foo.zip");
|
||||
if (File.Exists (tmpFile))
|
||||
File.Delete (tmpFile);
|
||||
|
||||
ZipFile.CreateFromDirectory ("foo", "foo.zip");
|
||||
Assert.IsTrue(File.Exists("foo.zip"));
|
||||
ZipFile.CreateFromDirectory ("foo", tmpFile);
|
||||
Assert.IsTrue(File.Exists(tmpFile));
|
||||
|
||||
using (var archive = new ZipArchive (File.Open ("foo.zip", FileMode.Open),
|
||||
using (var archive = new ZipArchive (File.Open (tmpFile, FileMode.Open),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
Assert.IsNotNull (archive.GetEntry ("foo.txt"));
|
||||
@@ -65,14 +72,14 @@ namespace MonoTests.System.IO.Compression.FileSystem
|
||||
[Test]
|
||||
public void ZipCreateFromDirectoryIncludeBase()
|
||||
{
|
||||
if (File.Exists ("foo.zip"))
|
||||
File.Delete ("foo.zip");
|
||||
if (File.Exists (tmpFile))
|
||||
File.Delete (tmpFile);
|
||||
|
||||
ZipFile.CreateFromDirectory ("foo", "foo.zip", CompressionLevel.Fastest,
|
||||
ZipFile.CreateFromDirectory ("foo", tmpFile, CompressionLevel.Fastest,
|
||||
includeBaseDirectory: true);
|
||||
Assert.IsTrue (File.Exists ("foo.zip"));
|
||||
Assert.IsTrue (File.Exists (tmpFile));
|
||||
|
||||
using (var archive = new ZipArchive (File.Open ("foo.zip", FileMode.Open),
|
||||
using (var archive = new ZipArchive (File.Open (tmpFile, FileMode.Open),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
Assert.IsNotNull (archive.GetEntry ("foo/foo.txt"));
|
||||
@@ -86,34 +93,35 @@ namespace MonoTests.System.IO.Compression.FileSystem
|
||||
[Test]
|
||||
public void ZipExtractToDirectory()
|
||||
{
|
||||
if (Directory.Exists ("extract"))
|
||||
Directory.Delete ("extract", true);
|
||||
var extractDir = Path.Combine (Path.GetTempPath (), "extract");
|
||||
if (Directory.Exists (extractDir))
|
||||
Directory.Delete (extractDir, true);
|
||||
|
||||
if (File.Exists ("foo.zip"))
|
||||
File.Delete ("foo.zip");
|
||||
if (File.Exists (tmpFile))
|
||||
File.Delete (tmpFile);
|
||||
|
||||
ZipFile.CreateFromDirectory ("foo", "foo.zip");
|
||||
ZipFile.CreateFromDirectory ("foo", tmpFile);
|
||||
|
||||
ZipFile.ExtractToDirectory ("foo.zip", "extract");
|
||||
Assert.IsTrue(Directory.Exists ("extract"));
|
||||
ZipFile.ExtractToDirectory (tmpFile, extractDir);
|
||||
Assert.IsTrue(Directory.Exists (extractDir));
|
||||
|
||||
Assert.IsTrue (File.Exists ("extract/foo.txt"));
|
||||
Assert.IsTrue (File.Exists ("extract/bar.txt"));
|
||||
Assert.IsTrue (Directory.Exists ("extract/foobar"));
|
||||
Assert.IsTrue (File.Exists ("extract/foobar/foo.txt"));
|
||||
Assert.IsTrue (File.Exists ("extract/foobar/bar.txt"));
|
||||
Assert.IsTrue (File.Exists (Path.Combine (extractDir, "foo.txt")), Path.Combine (extractDir, "foo.txt"));
|
||||
Assert.IsTrue (File.Exists (Path.Combine (extractDir, "bar.txt")), Path.Combine (extractDir, "bar.txt"));
|
||||
Assert.IsTrue (Directory.Exists (Path.Combine (extractDir, "foobar")), Path.Combine (extractDir, "foobar"));
|
||||
Assert.IsTrue (File.Exists (Path.Combine (extractDir, "foobar", "foo.txt")), Path.Combine (extractDir, "foobar", "foo.txt"));
|
||||
Assert.IsTrue (File.Exists (Path.Combine (extractDir, "foobar", "bar.txt")), Path.Combine (extractDir, "foobar", "bar.txt"));
|
||||
|
||||
Directory.Delete ("extract", true);
|
||||
Directory.Delete (extractDir, true);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipCreateFromEntryChangeTimestamp()
|
||||
{
|
||||
if (File.Exists ("foo.zip"))
|
||||
File.Delete ("foo.zip");
|
||||
if (File.Exists (tmpFile))
|
||||
File.Delete (tmpFile);
|
||||
|
||||
var file = "foo/foo.txt";
|
||||
using (var archive = new ZipArchive(File.Open("foo.zip", FileMode.Create),
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Create),
|
||||
ZipArchiveMode.Update))
|
||||
{
|
||||
archive.CreateEntryFromFile(file, file);
|
||||
@@ -121,7 +129,7 @@ namespace MonoTests.System.IO.Compression.FileSystem
|
||||
|
||||
var date = File.GetLastWriteTimeUtc(file);
|
||||
|
||||
using (var archive = new ZipArchive (File.Open ("foo.zip", FileMode.Open),
|
||||
using (var archive = new ZipArchive (File.Open (tmpFile, FileMode.Open),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
var entry = archive.GetEntry (file);
|
||||
|
@@ -1,5 +1,4 @@
|
||||
//
|
||||
// ZipTests.cs
|
||||
// ZipTests.cs
|
||||
//
|
||||
// Author:
|
||||
// Joao Matos <joao.matos@xamarin.com>
|
||||
@@ -48,8 +47,9 @@ namespace MonoTests.System.IO.Compression
|
||||
[Test]
|
||||
public void ZipGetEntryReadMode()
|
||||
{
|
||||
File.Copy("archive.zip", "test.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
var entry = archive.GetEntry("foo.txt");
|
||||
@@ -59,14 +59,15 @@ namespace MonoTests.System.IO.Compression
|
||||
Assert.IsNull(nullEntry);
|
||||
}
|
||||
|
||||
File.Delete ("test.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipGetEntryCreateMode()
|
||||
{
|
||||
File.Copy("archive.zip", "test.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Create))
|
||||
{
|
||||
try {
|
||||
@@ -78,14 +79,15 @@ namespace MonoTests.System.IO.Compression
|
||||
Assert.Fail();
|
||||
}
|
||||
|
||||
File.Delete ("test.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipGetEntryUpdateMode()
|
||||
{
|
||||
File.Copy("archive.zip", "test.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
var entry = archive.GetEntry("foo.txt");
|
||||
@@ -95,14 +97,15 @@ namespace MonoTests.System.IO.Compression
|
||||
Assert.IsNull(nullEntry);
|
||||
}
|
||||
|
||||
File.Delete ("test.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipGetEntryOpen()
|
||||
{
|
||||
File.Copy("archive.zip", "test.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
var entry = archive.GetEntry("foo.txt");
|
||||
@@ -111,15 +114,16 @@ namespace MonoTests.System.IO.Compression
|
||||
var foo = entry.Open();
|
||||
}
|
||||
|
||||
File.Delete ("test.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipOpenAndReopenEntry()
|
||||
{
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
try {
|
||||
File.Copy("archive.zip", "test.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Update))
|
||||
{
|
||||
var entry = archive.GetEntry("foo.txt");
|
||||
@@ -136,7 +140,7 @@ namespace MonoTests.System.IO.Compression
|
||||
Assert.Fail();
|
||||
}
|
||||
} finally {
|
||||
File.Delete ("test.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,8 +148,9 @@ namespace MonoTests.System.IO.Compression
|
||||
[Test]
|
||||
public void ZipOpenCloseAndReopenEntry()
|
||||
{
|
||||
File.Copy("archive.zip", "test.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Update))
|
||||
{
|
||||
var entry = archive.GetEntry("foo.txt");
|
||||
@@ -156,14 +161,15 @@ namespace MonoTests.System.IO.Compression
|
||||
stream = entry.Open();
|
||||
}
|
||||
|
||||
File.Delete ("test.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipGetEntryDeleteReadMode()
|
||||
{
|
||||
File.Copy("archive.zip", "delete.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Update))
|
||||
{
|
||||
var entry = archive.GetEntry("foo.txt");
|
||||
@@ -172,21 +178,22 @@ namespace MonoTests.System.IO.Compression
|
||||
entry.Delete();
|
||||
}
|
||||
|
||||
using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open),
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
var entry = archive.GetEntry("foo.txt");
|
||||
Assert.IsNull(entry);
|
||||
}
|
||||
|
||||
File.Delete ("delete.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipDeleteEntryCheckEntries()
|
||||
{
|
||||
File.Copy("archive.zip", "delete.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Update))
|
||||
{
|
||||
var entry = archive.GetEntry("foo.txt");
|
||||
@@ -197,14 +204,15 @@ namespace MonoTests.System.IO.Compression
|
||||
Assert.IsNull(archive.Entries.FirstOrDefault(e => e == entry));
|
||||
}
|
||||
|
||||
File.Delete ("delete.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipGetEntryDeleteUpdateMode()
|
||||
{
|
||||
File.Copy("archive.zip", "delete.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Update))
|
||||
{
|
||||
var entry = archive.GetEntry("foo.txt");
|
||||
@@ -213,20 +221,21 @@ namespace MonoTests.System.IO.Compression
|
||||
entry.Delete();
|
||||
}
|
||||
|
||||
using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open),
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
var entry = archive.GetEntry("foo.txt");
|
||||
Assert.IsNull(entry);
|
||||
}
|
||||
|
||||
File.Delete ("delete.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipCreateArchive()
|
||||
{
|
||||
using (var archive = new ZipArchive(File.Open("create.zip", FileMode.Create),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Create),
|
||||
ZipArchiveMode.Create))
|
||||
{
|
||||
var dir = archive.CreateEntry("foobar/");
|
||||
@@ -239,7 +248,7 @@ namespace MonoTests.System.IO.Compression
|
||||
}
|
||||
}
|
||||
|
||||
using (var archive = new ZipArchive(File.Open("create.zip", FileMode.Open),
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
Assert.IsNotNull(archive.GetEntry("foobar/"));
|
||||
@@ -253,22 +262,23 @@ namespace MonoTests.System.IO.Compression
|
||||
Assert.AreEqual("foo", text);
|
||||
}
|
||||
|
||||
File.Delete ("create.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipEnumerateEntriesModifiedTime()
|
||||
{
|
||||
File.Copy("archive.zip", "test.zip", overwrite: true);
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
var date = DateTimeOffset.Now;
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Update))
|
||||
{
|
||||
var entry = archive.GetEntry("foo.txt");
|
||||
entry.LastWriteTime = date;
|
||||
}
|
||||
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
var entry = archive.GetEntry("foo.txt");
|
||||
@@ -278,25 +288,29 @@ namespace MonoTests.System.IO.Compression
|
||||
|
||||
}
|
||||
|
||||
File.Delete ("test.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipEnumerateArchiveDefaultLastWriteTime()
|
||||
{
|
||||
using (var archive = new ZipArchive(File.Open("test.nupkg", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("test.nupkg", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
var entry = archive.GetEntry("_rels/.rels");
|
||||
Assert.AreEqual(new DateTime(624511296000000000).Ticks, entry.LastWriteTime.Ticks);
|
||||
Assert.IsNotNull(entry);
|
||||
}
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
public void ZipGetArchiveEntryStreamLengthPosition(ZipArchiveMode mode)
|
||||
{
|
||||
File.Copy("test.nupkg", "test2.nupkg", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("test2.nupkg", FileMode.Open), mode))
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("test.nupkg", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite), mode))
|
||||
{
|
||||
var entry = archive.GetEntry("_rels/.rels");
|
||||
using (var stream = entry.Open())
|
||||
@@ -316,7 +330,7 @@ namespace MonoTests.System.IO.Compression
|
||||
}
|
||||
}
|
||||
}
|
||||
File.Delete ("test2.nupkg");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -334,8 +348,9 @@ namespace MonoTests.System.IO.Compression
|
||||
[Test]
|
||||
public void ZipEnumerateEntriesReadMode()
|
||||
{
|
||||
File.Copy("archive.zip", "test.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
var entries = archive.Entries;
|
||||
@@ -348,14 +363,15 @@ namespace MonoTests.System.IO.Compression
|
||||
Assert.AreEqual("foobar/foo.txt", entries[4].FullName);
|
||||
}
|
||||
|
||||
File.Delete ("test.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipWriteEntriesUpdateMode()
|
||||
{
|
||||
File.Copy("archive.zip", "test.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Update))
|
||||
{
|
||||
var foo = archive.GetEntry("foo.txt");
|
||||
@@ -366,7 +382,7 @@ namespace MonoTests.System.IO.Compression
|
||||
}
|
||||
}
|
||||
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
var foo = archive.GetEntry("foo.txt");
|
||||
@@ -378,7 +394,7 @@ namespace MonoTests.System.IO.Compression
|
||||
}
|
||||
}
|
||||
|
||||
File.Delete ("test.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -418,8 +434,9 @@ namespace MonoTests.System.IO.Compression
|
||||
[Test]
|
||||
public void ZipWriteEntriesUpdateModeNonZeroPosition()
|
||||
{
|
||||
File.Copy("archive.zip", "test.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Update))
|
||||
{
|
||||
var foo = archive.GetEntry("foo.txt");
|
||||
@@ -433,7 +450,7 @@ namespace MonoTests.System.IO.Compression
|
||||
}
|
||||
}
|
||||
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
var entries = archive.Entries;
|
||||
@@ -446,14 +463,15 @@ namespace MonoTests.System.IO.Compression
|
||||
}
|
||||
}
|
||||
|
||||
File.Delete ("test.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipEnumerateEntriesUpdateMode()
|
||||
{
|
||||
File.Copy("archive.zip", "test.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
|
||||
ZipArchiveMode.Read))
|
||||
{
|
||||
var entries = archive.Entries;
|
||||
@@ -466,14 +484,15 @@ namespace MonoTests.System.IO.Compression
|
||||
Assert.AreEqual("foobar/foo.txt", entries[4].FullName);
|
||||
}
|
||||
|
||||
File.Delete ("test.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipEnumerateEntriesCreateMode()
|
||||
{
|
||||
File.Copy("archive.zip", "test.zip", overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("archive.zip", tmpFile, overwrite: true);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open),
|
||||
ZipArchiveMode.Create))
|
||||
{
|
||||
try {
|
||||
@@ -485,18 +504,19 @@ namespace MonoTests.System.IO.Compression
|
||||
Assert.Fail();
|
||||
}
|
||||
|
||||
File.Delete ("test.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipUpdateEmptyArchive()
|
||||
{
|
||||
File.WriteAllText("empty.zip", string.Empty);
|
||||
using (var archive = new ZipArchive(File.Open("empty.zip", FileMode.Open),
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.WriteAllText(tmpFile, string.Empty);
|
||||
using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open),
|
||||
ZipArchiveMode.Update))
|
||||
{
|
||||
}
|
||||
File.Delete ("empty.zip");
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
class MyFakeStream : FileStream
|
||||
@@ -517,21 +537,28 @@ namespace MonoTests.System.IO.Compression
|
||||
[Test]
|
||||
public void ZipReadNonSeekableStream()
|
||||
{
|
||||
var stream = new MyFakeStream("test.nupkg", FileMode.Open);
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("test.nupkg", tmpFile, overwrite: true);
|
||||
var stream = new MyFakeStream(tmpFile, FileMode.Open);
|
||||
using (var archive = new ZipArchive (stream, ZipArchiveMode.Read))
|
||||
{
|
||||
}
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ZipWriteNonSeekableStream() {
|
||||
var stream = new MyFakeStream( "test.nupkg", FileMode.Open );
|
||||
public void ZipWriteNonSeekableStream()
|
||||
{
|
||||
var tmpFile = Path.GetTempFileName ();
|
||||
File.Copy("test.nupkg", tmpFile, overwrite: true);
|
||||
var stream = new MyFakeStream(tmpFile, FileMode.Open );
|
||||
using ( var archive = new ZipArchive( stream, ZipArchiveMode.Create ) ) {
|
||||
var entry = archive.CreateEntry( "foo" );
|
||||
using ( var es = entry.Open() ) {
|
||||
es.Write( new byte[] { 4, 2 }, 0, 2 );
|
||||
}
|
||||
}
|
||||
File.Delete (tmpFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -334,6 +334,20 @@ namespace System.Net.Http
|
||||
return response;
|
||||
}
|
||||
|
||||
static bool MethodHasBody (HttpMethod method)
|
||||
{
|
||||
switch (method.Method) {
|
||||
case "HEAD":
|
||||
case "GET":
|
||||
case "MKCOL":
|
||||
case "CONNECT":
|
||||
case "TRACE":
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected async internal override Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (disposed)
|
||||
@@ -378,7 +392,7 @@ namespace System.Net.Http
|
||||
using (var stream = await wrequest.GetRequestStreamAsync ().ConfigureAwait (false)) {
|
||||
await request.Content.CopyToAsync (stream).ConfigureAwait (false);
|
||||
}
|
||||
} else if (HttpMethod.Post.Equals (request.Method) || HttpMethod.Put.Equals (request.Method) || HttpMethod.Delete.Equals (request.Method)) {
|
||||
} else if (MethodHasBody (request.Method)) {
|
||||
// Explicitly set this to make sure we're sending a "Content-Length: 0" header.
|
||||
// This fixes the issue that's been reported on the forums:
|
||||
// http://forums.xamarin.com/discussion/17770/length-required-error-in-http-post-since-latest-release
|
||||
|
@@ -26,7 +26,7 @@
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
@@ -291,4 +291,4 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -27,7 +27,7 @@
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if !MOBILE
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
@@ -160,4 +160,4 @@ namespace MonoTests.System.Security.Cryptography.Pkcs {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user