dotnet-storage/PoweredSoft.Storage.Test/S3Tests.cs

36 lines
1.2 KiB
C#
Raw Normal View History

2020-08-20 17:28:42 -04:00
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PoweredSoft.Storage.S3;
namespace PoweredSoft.Storage.Test
{
[TestClass]
public class S3Tests
{
[TestMethod]
public void NameValidation()
{
var space = GetMockS3Space();
Assert.IsFalse(space.IsFileNameAllowed("Operations .pdf"), "Should not be valid");
Assert.IsFalse(space.IsFileNameAllowed("Operations$$.pdf"), "Should not be valid");
}
[TestMethod]
public void NameSanitation()
{
var space = GetMockS3Space();
Assert.AreEqual("Operations_.pdf", space.SanitizeFileName("Operations .pdf", "_"), "does not match sanitation expectations");
Assert.AreEqual("Operations__.pdf", space.SanitizeFileName("Operations$$.pdf", "_"), "does not match sanitation expectations");
}
private static S3StorageProvider GetMockS3Space()
{
var space = new S3StorageProvider("http://localhost:9000", "mybucket", "myminio", "myexample");
space.SetForcePathStyle(true);
space.SetS3UsEast1RegionalEndpointValue(Amazon.Runtime.S3UsEast1RegionalEndpointValue.Legacy);
return space;
}
}
}