Beispiel #1
0
        public void CanGetFile_ByPath()
        {
            File f = (File)upload.GetChild("Folder 2/Folder 3/File 3.txt");

            Assert.That(f, Is.Not.Null);
            Assert.That(f.Name, Is.EqualTo("File 3.txt"));
        }
Beispiel #2
0
        public void CanGetFile_ByName()
        {
            File f = (File)upload.GetChild("File.txt");

            Assert.That(f, Is.Not.Null);
            Assert.That(f.Name, Is.EqualTo("File.txt"));
        }
Beispiel #3
0
        private void AssertMovement(Action <File, Directory> moveAction)
        {
            Directory sourceDirectory      = (Directory)upload.GetChild("Folder1");
            Directory destinationDirectory = (Directory)upload.GetChild("Folder 2");
            File      f = (File)sourceDirectory.GetChild("File1.txt");

            moveAction(f, destinationDirectory);
            Assert.That(sourceDirectory.GetChild("File1.txt"), Is.Null);
            Assert.That(f.Parent, Is.EqualTo(destinationDirectory));
            Assert.That(destinationDirectory.GetChild("File1.txt"), Is.Not.Null);
        }
Beispiel #4
0
        public void CanMoveFile_ToRootDirectory()
        {
            File   f               = (File)upload.GetChild("Folder 2/File 2.txt");
            string sourcePath      = MapPath(@"/Upload/Folder 2/File 2.txt");
            string destinationPath = MapPath(@"/Upload/File 2.txt");

            try
            {
                f.AddTo(upload);
                Assert.That(System.IO.File.Exists(destinationPath));
                Assert.That(!System.IO.File.Exists(sourcePath));
            }
            finally
            {
                if (System.IO.File.Exists(destinationPath))
                {
                    System.IO.File.Move(destinationPath, sourcePath);
                }
            }
        }
Beispiel #5
0
        private void CopyAndDelete(Func <File, Directory, ContentItem> copyAction)
        {
            Directory d1    = (Directory)upload.GetChild("Folder1");
            Directory d2    = (Directory)upload.GetChild("Folder 2");
            File      f     = (File)d1.GetChild("File1.txt");
            File      fCopy = null;

            try
            {
                fCopy = (File)copyAction(f, d2);
                Assert.That(d2.GetChild("File1.txt"), Is.Not.Null);
                Assert.That(fCopy.Parent, Is.EqualTo(d2));
                Assert.That(d1.GetChild("File1.txt"), Is.Not.Null);
                Assert.That(f.Parent, Is.EqualTo(d1));
            }
            finally
            {
                if (fCopy != null)
                {
                    fCopy.Delete();
                }
            }
        }
Beispiel #6
0
        public void MovingFile_TriggersEvent()
        {
            File      f               = (File)upload.GetChild("Folder 2/Folder 3/File 3.txt");
            string    sourcePath      = MapPath(@"/Upload/Folder 2/Folder 3/File 3.txt");
            string    destinationPath = MapPath(@"/Upload/Folder1/File 3.txt");
            Directory d               = (Directory)upload.GetChild("Folder1");

            try
            {
                f.AddTo(d);

                Assert.That(arguments[0].SourcePath, Is.EqualTo(@"/Upload/Folder 2/Folder 3/File 3.txt"));
                Assert.That(arguments[0].VirtualPath, Is.EqualTo(@"/Upload/Folder1/File 3.txt"));
                Assert.That(operations[0], Is.EqualTo("FileMoved"));
            }
            finally
            {
                if (System.IO.File.Exists(destinationPath))
                {
                    System.IO.File.Move(destinationPath, sourcePath);
                }
            }
        }
Beispiel #7
0
		private void AddSizeControl(ImageSizeElement size, string path, File file, ContentItem child)
		{
			if (path == null)
				throw new ArgumentNullException("path");
			if (file == null)
				throw new ArgumentNullException("file");
			if (child == null)
				throw new ArgumentNullException("child");

			var hl = new HyperLink { ID = size.Name + "Size" };
			hl.NavigateUrl = "File.aspx?selected=" + child.Path;
			hl.Text = Utility.GetResourceString("ImageSizes", size.Name + ".Text") ?? (string.IsNullOrEmpty(size.Description) ? size.Name : size.Description);
			hl.Text += GetSizeText(size.Width, size.Height);
			hl.CssClass = "command";
			if (bgSizes == null)
				throw new ArgumentNullException("bgSizes");

			if (path == Selection.SelectedItem.Url)
				bgSizes.Controls.AddAt(0, hl);
			else
				bgSizes.Controls.Add(hl);
		}
Beispiel #8
0
        public void CanGet_FileLength()
        {
            File f = (File)upload.GetChild("File.txt");

            Assert.That(f.Size, Is.EqualTo(13));
        }
Beispiel #9
0
 internal void Add(File file)
 {
     file.Parent = this;
     Children.Add(file);
 }
Beispiel #10
0
		public void CanUpdateUrl_ToMultipleImage()
		{
			RootDirectory rootDir;
			FakeMemoryFileSystem fs;
			SetupFileSystem(out rootDir, out fs);
			fs.files["/FileSystem/upload/Image.jpg"] = new FileData { Name = "Image.jpg" };
			fs.files["/FileSystem/upload/OtherImage.jpg"] = new FileData { Name = "OtherImage.jpg" };

			string propertyName1 = "TestDetail";
			string propertyName2 = "SuperDetail";

			root[propertyName1] = @"<img src=""/FileSystem/upload/Image.jpg"" /><img src=""/FileSystem/upload/OtherImage.jpg"" />";
			item1[propertyName2] = @"<img src=""/FileSystem/upload/Image.jpg"" />";

			persister.Save(root);
			persister.Save(item1);
			
			var file = new File(fs.GetFile("/FileSystem/upload/Image.jpg"), new Directory(fs.GetDirectory("/FileSystem/upload/"), rootDir));
			file.Name = "Image2.jpg";

			tracker.UpdateReferencesTo(file, "/FileSystem/upload/Image.jpg", isRenamingDirectory: false);

			root[propertyName1].ShouldBe(@"<img src=""/FileSystem/upload/Image2.jpg"" /><img src=""/FileSystem/upload/OtherImage.jpg"" />");
			item1[propertyName2].ShouldBe(@"<img src=""/FileSystem/upload/Image2.jpg"" />");
		}
Beispiel #11
0
		public void UpdateUrl_ToImage_IgnoresCasing()
		{
			RootDirectory rootDir;
			FakeMemoryFileSystem fs;
			SetupFileSystem(out rootDir, out fs);
			fs.files["/FileSystem/upload/Image.jpg"] = new FileData { Name = "Image.jpg" };
			string propertyName1 = "TestDetail";
			root[propertyName1] = @"<img src=""/FileSystem/Upload/Image.jpg"" />";
			persister.Save(root);

			var file = new File(fs.GetFile("/FileSystem/upload/Image.jpg"), new Directory(fs.GetDirectory("/FileSystem/upload/"), rootDir));
			file.Name = "Image2.jpg";
			tracker.UpdateReferencesTo(file, "/filesystem/upload/image.jpg", isRenamingDirectory: false);

			root[propertyName1].ShouldBe(@"<img src=""/FileSystem/upload/Image2.jpg"" />");
		}