Esempio n. 1
0
        public void ToFileInfo_NoCreatedBy()
        {
            var releaseFile = new ReleaseFile
            {
                Release = new Release(),
                Name    = "Test ancillary file",
                File    = new File
                {
                    Id       = Guid.NewGuid(),
                    RootPath = Guid.NewGuid(),
                    Filename = "ancillary.pdf",
                    Type     = Ancillary,
                }
            };

            var info = releaseFile.ToFileInfo(new BlobInfo
                                              (
                                                  path: "Ignored",
                                                  size: "400 B",
                                                  contentType: "Ignored",
                                                  contentLength: -1L,
                                                  meta: new Dictionary <string, string>()
                                              ));

            Assert.Null(info.Created);
            Assert.Null(info.UserName);
        }
        private async Task <FileInfo> GetReleaseFileInfo(ReleaseFile releaseFile)
        {
            var blobExists = await _blobStorageService.CheckBlobExists(
                PrivateReleaseFiles,
                releaseFile.Path()
                );

            if (!blobExists)
            {
                return(releaseFile.ToFileInfoNotFound());
            }

            var blob = await _blobStorageService.GetBlob(PrivateReleaseFiles, releaseFile.Path());

            return(releaseFile.ToFileInfo(blob));
        }
Esempio n. 3
0
        public void ToFileInfo()
        {
            var releaseFile = new ReleaseFile
            {
                Release = new Release(),
                Name    = "Test ancillary file",
                Summary = "Test summary",
                File    = new File
                {
                    Id        = Guid.NewGuid(),
                    RootPath  = Guid.NewGuid(),
                    Filename  = "ancillary.pdf",
                    Type      = Ancillary,
                    Created   = new DateTime(),
                    CreatedBy = new User
                    {
                        Email = "*****@*****.**"
                    }
                }
            };

            var info = releaseFile.ToFileInfo(new BlobInfo
                                              (
                                                  path: "Ignored",
                                                  size: "400 B",
                                                  contentType: "Ignored",
                                                  contentLength: -1L,
                                                  meta: new Dictionary <string, string>()
                                              ));

            Assert.Equal(releaseFile.FileId, info.Id);
            Assert.Equal("pdf", info.Extension);
            Assert.Equal("ancillary.pdf", info.FileName);
            Assert.Equal("Test ancillary file", info.Name);
            Assert.Equal("Test summary", info.Summary);
            Assert.Equal("400 B", info.Size);
            Assert.Equal(Ancillary, info.Type);
            Assert.Equal(releaseFile.File.Created, info.Created);
            Assert.Equal("*****@*****.**", info.UserName);
        }
        private async Task <FileInfo> ToAncillaryFileInfo(ReleaseFile releaseFile, BlobInfo blobInfo)
        {
            await HydrateReleaseFile(releaseFile);

            return(releaseFile.ToFileInfo(blobInfo));
        }