Example #1
0
        public void TestUpload()
        {
            var fileName              = "Test file name.png";
            var server                = new ServerMock();
            var uploadHelper          = new UploadHelper(server);
            UploadedFileMock mockFile = new UploadedFileMock();

            mockFile.SetContentLength(2);
            mockFile.SetFileName(fileName);

            var uploadPath = uploadHelper.Upload(mockFile);

            Assert.AreEqual(uploadPath, server.MapPath(UploadHelper.UploadDirectory + fileName));
        }
Example #2
0
        public void TestDuplicateUpload()
        {
            var duplicateFileName = "Duplicate image.png";
            var server            = new ServerMock();
            var uploadHelper      = new UploadHelper(server);

            var duplicateFilePath = server.MapPath("~" + duplicateFileName);

            File.Create(duplicateFilePath).Dispose();

            UploadedFileMock mockFile = new UploadedFileMock();

            mockFile.SetContentLength(2);
            mockFile.SetFileName(duplicateFileName);

            var filePath = uploadHelper.Upload(mockFile);


            File.Delete(duplicateFilePath);

            Assert.AreEqual(filePath, server.MapPath(UploadHelper.UploadDirectory + "Duplicate image(1).png"));
        }