public void NoArguments() { var cmd = new Cmd.CopyItem(); InitCommand(cmd); var res = cmd.Run(); Assert.AreEqual(CommandStatus.Failure, res.Status); }
public void ContextToExistingPath() { var cmd = new Cmd.CopyItem(); InitCommand(cmd); var sourceItem = _singleTestRoot.Add("source", _template); var targetItem = _singleTestRoot.Add("target", _template); _context.CurrentItem = sourceItem; cmd.TargetPath = targetItem.Paths.FullPath; var res = cmd.Run(); targetItem.Reload(); Assert.AreEqual(CommandStatus.Success, res.Status); Assert.AreEqual(1, targetItem.GetChildren().Count); Assert.AreEqual(sourceItem.Name, targetItem.Children[0].Name); }
public void ContextToSelf() { var cmd = new Cmd.CopyItem(); InitCommand(cmd); var sourceItem = _singleTestRoot.Add("source", _template); _context.CurrentItem = sourceItem; cmd.TargetPath = "."; var res = cmd.Run(); Assert.AreEqual(CommandStatus.Success, res.Status); Assert.AreEqual(1, sourceItem.GetChildren().Count); Assert.AreEqual(sourceItem.Name, sourceItem.Children[0].Name); }
public void CopyMediaToDifferentDB() { var cmd = new Cmd.CopyItem(); InitCommand(cmd); var targetPath = "/sitecore/media library/images/test-image"; var image = AddTestImageToMaster(); _context.CurrentItem = image; cmd.TargetPath = "/web" + targetPath; var res = cmd.Run(); Assert.AreEqual(CommandStatus.Success, res.Status); var webImage = Factory.GetDatabase("web").GetItem(targetPath); Assert.IsNotNull(webImage); Stream stream = ((MediaItem)webImage).GetMediaStream(); Assert.IsNotNull(stream); Assert.Greater(stream.Length, 0); }
public void CopyMedia() { var cmd = new Cmd.CopyItem(); InitCommand(cmd); var image = AddTestImageToMaster(); var targetItem = image.InnerItem.Add("target", _template); _context.CurrentItem = image; cmd.TargetPath = targetItem.Paths.FullPath + "/newpath"; var res = cmd.Run(); targetItem.Reload(); Assert.AreEqual(CommandStatus.Success, res.Status); Assert.AreEqual(1, targetItem.GetChildren().Count); Assert.AreEqual("newpath", targetItem.Children[0].Name); Stream stream = ((MediaItem)targetItem.Children[0]).GetMediaStream(); Assert.IsNotNull(stream); Assert.Greater(stream.Length, 0); }
public void CopyMediaRecursive() { var cmd = new Cmd.CopyItem(); InitCommand(cmd); var mediaFolder = CreateImageFoldersInMaster(); var targetItem = _mediaTestRoot.Add("target-" + DateUtil.IsoNow, _template); _context.CurrentItem = mediaFolder; cmd.TargetPath = targetItem.Paths.FullPath + "/newpath"; cmd.Recursive = true; var res = cmd.Run(); targetItem.Reload(); Assert.AreEqual(CommandStatus.Success, res.Status); Assert.AreEqual(1, targetItem.GetChildren().Count); Assert.AreEqual("newpath", targetItem.Children[0].Name); Assert.AreEqual(2, targetItem.Children[0].GetChildren().Count); var stream = ((MediaItem)targetItem.Children[0].Children[0]).GetMediaStream(); Assert.IsNotNull(stream); Assert.Greater(stream.Length, 0); var stream2 = ((MediaItem)targetItem.Children[0].Children[1]).GetMediaStream(); Assert.IsNotNull(stream2); Assert.Greater(stream2.Length, 0); }
public void DisallowCopyToVersion() { var cmd = new Cmd.CopyItem(); InitCommand(cmd); cmd.TargetPath = "::2"; var result = cmd.Run(); Assert.That(result.Status, Is.EqualTo(CommandStatus.Failure)); }
public void InvalidTarget() { var cmd = new Cmd.CopyItem(); InitCommand(cmd); var sourceItem = _singleTestRoot.Add("source", _template); _context.CurrentItem = _singleTestRoot.Parent; cmd.SourcePath = _singleTestRoot.Name + "/" + sourceItem.Name; cmd.TargetPath = "/sitecore/content/thia/path/doesnt/exist"; var res = cmd.Run(); Assert.AreEqual(CommandStatus.Failure, res.Status); }
public void DifferentItemToExistingPathRelative() { var cmd = new Cmd.CopyItem(); InitCommand(cmd); var sourceItem = _singleTestRoot.Add("source", _template); var targetItem = _singleTestRoot.Add("target", _template); _context.CurrentItem = _singleTestRoot.Parent; cmd.SourcePath = _singleTestRoot.Name + "/" + sourceItem.Name; cmd.TargetPath = _singleTestRoot.Name + "/" + targetItem.Name; var res = cmd.Run(); targetItem.Reload(); Assert.AreEqual(CommandStatus.Success, res.Status); Assert.AreEqual(1, targetItem.GetChildren().Count); Assert.AreEqual(sourceItem.Name, targetItem.Children[0].Name); Assert.AreEqual(0, targetItem.Children[0].GetChildren().Count); }
public void ContextToDBDifferentID() { var cmd = new Cmd.CopyItem(); InitCommand(cmd); var sourceItem = _singleTestRoot.Add("source", _template); _context.CurrentItem = sourceItem; cmd.TargetPath = "/master/sitecore/content/" + _masterTestRoot.Name; cmd.NewId = true; var res = cmd.Run(); _masterTestRoot.Reload(); var masterCopy = _masterTestRoot.Axes.GetChild(sourceItem.Name); Assert.AreEqual(CommandStatus.Success, res.Status); Assert.IsNotNull(masterCopy); Assert.AreNotEqual(sourceItem.ID, masterCopy.ID); }
public void ContextToNewPathFromTreeNonRecursive() { var cmd = new Cmd.CopyItem(); InitCommand(cmd); var sourceItem = _singleTestRoot.Add("source", _template); var sourceChildItem = sourceItem.Add("child1", _template); var targetItem = _singleTestRoot.Add("target", _template); _context.CurrentItem = sourceItem; cmd.TargetPath = targetItem.Paths.FullPath + "/newpath"; var res = cmd.Run(); targetItem.Reload(); Assert.AreEqual(CommandStatus.Success, res.Status); Assert.AreEqual(1, targetItem.GetChildren().Count); Assert.AreEqual("newpath", targetItem.Children[0].Name); Assert.AreEqual(0, targetItem.Children[0].GetChildren().Count); }