public void Upload_ShouldReturnUploadedFileWithFileIdGreaterThanZero_WhenAFileIsUploaded()
        {
            IFileService fileService = new StubIFileService()
            {
                UploadFileDataDetail = dd => { dd.FileDetail.FileId = 1; return dd; }
            };

            DefaultFileHandler defaultFileHandler = new DefaultFileHandler(fileService);
            DataFile dataFile = new DataFile() { FileContent = new byte[0] };
            DataDetail dataDetail = defaultFileHandler.Upload(dataFile).First();
            Assert.IsTrue(dataDetail.FileDetail.FileId > 0);
        }
Ejemplo n.º 2
0
 public void Upload_ShouldThrowArgumentException_WhenDataFileIsNull()
 {
     IFileService fileService = new StubIFileService();
     DefaultFileHandler defaultFileHandler = new DefaultFileHandler(fileService);
     try
     {
         defaultFileHandler.Upload(null);
         Assert.Fail("Should have exceptioned above!");
     }
     catch (Exception ex)
     {
         Assert.IsInstanceOfType(ex, typeof(ArgumentException));
         Assert.IsTrue(ex.Message.ToString().Contains("dataFile"));
     }
 }
Ejemplo n.º 3
0
        public void Upload_ShouldReturnUploadedFileWithFileIdGreaterThanZero_WhenAFileIsUploaded()
        {
            IFileService fileService = new StubIFileService()
            {
                UploadFileDataDetail = dd => { dd.FileDetail.FileId = 1; return dd; }
            };

            DefaultFileHandler defaultFileHandler = new DefaultFileHandler(fileService);
            DataFile dataFile = new DataFile() { FileContent = new byte[0] };
            IEnumerable<DataDetail> dataDetails;
            List<DataFile> dataFiles = new List<DataFile>();
            dataFiles.Add(new DataFile() { FileContent = new byte[0] });
            dataFiles.Add(new DataFile() { FileContent = new byte[0] });

            using (ShimsContext.Create())
            {
                ShimZipUtilities.GetListOfFilesFromStreamStreamInt32 = (zipstream, userId) => dataFiles;
                dataDetails = defaultFileHandler.Upload(dataFile);
            }

            Assert.IsTrue(dataDetails.All(fd => fd.FileDetail.FileId > 0));
        }