Exemplo n.º 1
0
        public void BuildCorrectPathWithEmptyFileName()
        {
            var filePath = RelativeFilePathBuilder.GetRelativeFilePath(_fileId, _containerName, string.Empty);
            var expected = @"test-files\c3\b8\c3b836ef-ec43-4ac2-bba1-f477db3f480d";

            Assert.Equal(expected, filePath.Replace('/', '\\'));
        }
Exemplo n.º 2
0
 [InlineData("aa", false)]                                                               // 2 chars
 public void ArgumentExceptionForContainerWithUppercase(string containerName, bool isValid)
 {
     // This is to ensure compatibility with Azure containers, which only allows
     // lowercase alphanumeric chars and dash '-' container characters
     if (isValid)
     {
         Assert.False(string.IsNullOrWhiteSpace(RelativeFilePathBuilder.GetRelativeFilePath(_fileId, containerName, _fileName)));
     }
     else
     {
         Assert.Throws <ArgumentException>("container", () => RelativeFilePathBuilder.GetRelativeFilePath(_fileId, containerName, _fileName));
     }
 }
Exemplo n.º 3
0
        public void TruncatesFilenameIfTooLong()
        {
            // The file name part has a max length of 1024 chars to be compatible with Azure
            // storage limits
            var fileName     = new string('a', 1024);
            var filePath     = RelativeFilePathBuilder.GetRelativeFilePath(_fileId, _containerName, fileName);
            var expectedBase = @"test-files\c3\b8\";
            var guidPart     = "c3b836ef-ec43-4ac2-bba1-f477db3f480d";
            var fileNamePart = "_" + new string('a', 1024 - guidPart.Length - 1); // -1 for the dash
            var expected     = expectedBase + guidPart + fileNamePart;

            Assert.Equal(expected, filePath.Replace('/', '\\'));
            Assert.True(filePath.Length <= 1024 + expectedBase.Length);
        }
Exemplo n.º 4
0
 public void ArgumentNullExceptionForEmptyContainerName()
 {
     Assert.Throws <ArgumentNullException>("container", () => RelativeFilePathBuilder.GetRelativeFilePath(_fileId, string.Empty, _fileName));
 }