You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
5.0 KiB

  1. /*
  2. * MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2017 MinIO, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. using Microsoft.VisualStudio.TestTools.UnitTesting;
  17. using Minio.Exceptions;
  18. using System;
  19. using System.Net;
  20. namespace Minio.Tests
  21. {
  22. /// <summary>
  23. /// Summary description for UnitTest1
  24. /// </summary>
  25. [TestClass, Ignore("Class was previously skipped by unit tests.. See #211")]
  26. public class UnitTest1
  27. {
  28. public UnitTest1()
  29. {
  30. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
  31. | SecurityProtocolType.Tls11
  32. | SecurityProtocolType.Tls12;
  33. var minio = new MinioClient("play.min.io",
  34. "Q3AM3UQ867SPQQA43P2F",
  35. "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
  36. }
  37. private TestContext testContextInstance;
  38. /// <summary>
  39. ///Gets or sets the test context which provides
  40. ///information about and functionality for the current test run.
  41. ///</summary>
  42. public TestContext TestContext
  43. {
  44. get
  45. {
  46. return testContextInstance;
  47. }
  48. set
  49. {
  50. testContextInstance = value;
  51. }
  52. }
  53. #region Additional test attributes
  54. //
  55. // You can use the following additional attributes as you write your tests:
  56. //
  57. // Use ClassInitialize to run code before running the first test in the class
  58. // [ClassInitialize()]
  59. // public static void MyClassInitialize(TestContext testContext) { }
  60. //
  61. // Use ClassCleanup to run code after all tests in a class have run
  62. // [ClassCleanup()]
  63. // public static void MyClassCleanup() { }
  64. //
  65. // Use TestInitialize to run code before running each test
  66. // [TestInitialize()]
  67. // public void MyTestInitialize() { }
  68. //
  69. // Use TestCleanup to run code after each test has run
  70. // [TestCleanup()]
  71. // public void MyTestCleanup() { }
  72. //
  73. #endregion
  74. [TestMethod]
  75. public void TestWithUrl()
  76. {
  77. new MinioClient(endpoint:"http://localhost:9000");
  78. }
  79. [TestMethod]
  80. public void TestWithoutPort()
  81. {
  82. new MinioClient("http://localhost");
  83. }
  84. [TestMethod]
  85. public void TestWithTrailingSlash()
  86. {
  87. new MinioClient("http://localhost:9000/");
  88. }
  89. [TestMethod]
  90. [ExpectedException(typeof(InvalidEndpointException))]
  91. public void TestUrlFailsWithMalformedScheme()
  92. {
  93. new MinioClient("htp://localhost:9000");
  94. }
  95. [TestMethod]
  96. [ExpectedException(typeof(InvalidEndpointException))]
  97. public void TestUrlFailsWithPath()
  98. {
  99. new MinioClient("http://localhost:9000/foo");
  100. }
  101. [TestMethod]
  102. [ExpectedException(typeof(InvalidEndpointException))]
  103. public void TestUrlFailsWithQuery()
  104. {
  105. new MinioClient("http://localhost:9000/?foo=bar");
  106. }
  107. [TestMethod]
  108. [ExpectedException(typeof(ArgumentException))]
  109. public void TestSetAppInfoFailsNullApp()
  110. {
  111. var client = new MinioClient("http://localhost:9000");
  112. client.SetAppInfo(null, "1.2.2");
  113. }
  114. [TestMethod]
  115. [ExpectedException(typeof(ArgumentException))]
  116. public void TestSetAppInfoFailsNullVersion()
  117. {
  118. var client = new MinioClient("http://localhost:9000");
  119. client.SetAppInfo("Hello-App", null);
  120. }
  121. [TestMethod]
  122. public void TestSetAppInfoSuccess()
  123. {
  124. var client = new MinioClient("http://localhost:9000");
  125. client.SetAppInfo("Hello-App", "1.2.1");
  126. }
  127. [TestMethod]
  128. public void TestEndpointSuccess()
  129. {
  130. new MinioClient("s3.amazonaws.com");
  131. }
  132. [TestMethod]
  133. [ExpectedException(typeof(InvalidEndpointException))]
  134. public void TestEndpointFailure()
  135. {
  136. new MinioClient("s3-us-west-1.amazonaws.com");
  137. }
  138. //[TestMethod]
  139. //[ExpectedException(typeof(ArgumentException))]
  140. //public void TestPutObject()
  141. //{
  142. // var client = new MinioClient("localhost", 9000);
  143. // await client.PutObjectAsync("bucket-name", "object-name", null, 5 * 1024L * 1024L * 11000, null);
  144. //}
  145. }
  146. }