本文整理汇总了C#中MoveDelegate类的典型用法代码示例。如果您正苦于以下问题:C# MoveDelegate类的具体用法?C# MoveDelegate怎么用?C# MoveDelegate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MoveDelegate类属于命名空间,在下文中一共展示了MoveDelegate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveToMissingFolder
private void MoveToMissingFolder(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var testDef = new ProjectDefinition("MoveToMissingFolder",
projectType,
PropertyGroup(
Property("ProjectView", "ShowAllFiles")
),
ItemGroup(
Folder("Fob", isExcluded: false, isMissing: true),
Compile("codefile", isExcluded: false)
)
);
using (var solution = testDef.Generate().ToVs()) {
mover(
solution,
solution.FindItem("MoveToMissingFolder", "Fob"),
solution.FindItem("MoveToMissingFolder", "codefile" + projectType.CodeExtension)
);
solution.AssertFileDoesntExist("MoveToMissingFolder", "codefile" + projectType.CodeExtension);
solution.AssertFileExists("MoveToMissingFolder", "Fob", "codefile" + projectType.CodeExtension);
}
}
}
示例2: MoveExcludedFolder
private void MoveExcludedFolder(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var testDef = new ProjectDefinition("MoveExcludedFolder",
projectType,
PropertyGroup(
Property("ProjectView", "ShowAllFiles")
),
ItemGroup(
Folder("Fob", isExcluded: true),
Folder("Fob\\Oar", isExcluded: true),
Folder("Baz", isExcluded: true)
)
);
using (var solution = testDef.Generate().ToVs()) {
mover(
solution,
solution.FindItem("MoveExcludedFolder", "Baz"),
solution.FindItem("MoveExcludedFolder", "Fob")
);
solution.AssertFolderDoesntExist("MoveExcludedFolder", "Fob");
solution.AssertFolderExists("MoveExcludedFolder", "Baz", "Fob");
}
}
}
示例3: MultiPaste
/// <summary>
/// Cut item, paste into folder, paste into top-level, 2nd paste should prompt for overwrite
/// </summary>
private void MultiPaste(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var testDef = new ProjectDefinition("HelloWorld",
projectType,
ItemGroup(
Compile("server"),
Compile("server2"),
Folder("SubFolder")
)
);
using (var solution = testDef.Generate().ToVs()) {
var server = solution.WaitForItem("HelloWorld", "server" + projectType.CodeExtension);
var server2 = solution.WaitForItem("HelloWorld", "server2" + projectType.CodeExtension);
mover(
solution,
solution.WaitForItem("HelloWorld", "SubFolder"),
solution.WaitForItem("HelloWorld", "server" + projectType.CodeExtension),
solution.WaitForItem("HelloWorld", "server2" + projectType.CodeExtension)
);
// paste once, multiple items should be pasted
Assert.IsNotNull(solution.WaitForItem("HelloWorld", "SubFolder", "server" + projectType.CodeExtension));
Assert.IsNotNull(solution.WaitForItem("HelloWorld", "SubFolder", "server2" + projectType.CodeExtension));
solution.SelectSolutionNode();
mover(
solution,
solution.WaitForItem("HelloWorld", "SubFolder"),
solution.WaitForItem("HelloWorld", "server" + projectType.CodeExtension),
solution.WaitForItem("HelloWorld", "server2" + projectType.CodeExtension)
);
// paste again, we should get the replace prompts...
using (var dialog = solution.WaitForOverwriteFileDialog()) {
dialog.Cancel();
}
// https://pytools.codeplex.com/workitem/1154
// and we shouldn't get a second dialog after cancelling...
solution.WaitForDialogDismissed();
}
}
}
示例4: MoveDuplicateFileNameDontOverwrite
/// <summary>
/// Cuts 2 files with the same name, pastes them to a folder, and makes
/// sure we get prompted to overwrite. Answers no to overwriting, both
/// files should still be in the project.
/// </summary>
/// <param name="mover"></param>
private void MoveDuplicateFileNameDontOverwrite(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var project = new ProjectDefinition(
"DragDropCopyCutPaste",
projectType,
ItemGroup(
Folder("A"),
Folder("B"),
Content("quox.txt", "top-level"),
Content("A\\quox.txt", "A")
)
);
using (var solution = project.Generate().ToVs()) {
mover(
solution.WaitForItem("DragDropCopyCutPaste", "B"),
solution.WaitForItem("DragDropCopyCutPaste", "A", "quox.txt"),
solution.WaitForItem("DragDropCopyCutPaste", "quox.txt")
);
using (var dialog = OverwriteFileDialog.Wait(solution.App)) {
AssertUtil.Contains(dialog.Text, "A file with the same name 'quox.txt' already exists.");
dialog.No();
}
solution.AssertFileExists("DragDropCopyCutPaste", "B", "quox.txt");
// one of the fils should still exist...
try {
solution.AssertFileExists("DragDropCopyCutPaste", "quox.txt");
} catch (AssertFailedException) {
solution.AssertFileExists("DragDropCopyCutPaste", "A", "quox.txt");
}
Assert.AreEqual(1, solution.Project.ProjectItems.Item("B").ProjectItems.Count);
}
}
}
示例5: MoveDuplicateFileNamesFoldersSkipOne
/// <summary>
/// Cut 2 items, paste where they exist, skip pasting the 1st one but paste the 2nd.
///
/// The 1st item shouldn't be removed from the parent hierarchy, the 2nd should, and only the 2nd item should be overwritten.
/// </summary>
private void MoveDuplicateFileNamesFoldersSkipOne(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var testDef = new ProjectDefinition("MoveDuplicateFileName",
projectType,
ItemGroup(
Folder("Source"),
Content("Source\\textfile1.txt", "source1"),
Content("Source\\textfile2.txt", "source2"),
Folder("Target"),
Content("Target\\textfile1.txt", "target1"),
Content("Target\\textfile2.txt", "target2")
)
);
using (var solution = testDef.Generate().ToVs()) {
mover(
solution,
solution.FindItem("MoveDuplicateFileName", "Target"),
solution.FindItem("MoveDuplicateFileName", "Source", "textfile1.txt"),
solution.FindItem("MoveDuplicateFileName", "Source", "textfile2.txt")
);
using (var dialog = solution.WaitForOverwriteFileDialog()) {
dialog.No();
}
System.Threading.Thread.Sleep(1000);
using (var dialog = solution.WaitForOverwriteFileDialog()) {
dialog.Yes();
}
solution.WaitForDialogDismissed();
solution.AssertFileExistsWithContent("source1", "MoveDuplicateFileName", "Source", "textfile1.txt");
solution.AssertFileDoesntExist("MoveDuplicateFileName", "textfile2.txt");
solution.AssertFileExistsWithContent("target1", "MoveDuplicateFileName", "Target", "textfile1.txt");
solution.AssertFileExistsWithContent("source2", "MoveDuplicateFileName", "Target", "textfile2.txt");
}
}
}
示例6: MoveDuplicateFileNameOverwrite
/// <summary>
/// Cuts 2 files with the same name, answers yes to overwrite them, and
/// makes sure only one file is left.
/// </summary>
/// <param name="mover"></param>
private void MoveDuplicateFileNameOverwrite(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var project = new ProjectDefinition(
"DragDropCopyCutPaste",
projectType,
ItemGroup(
Folder("A"),
Folder("B"),
Content("quox.txt", "top-level"),
Content("A\\quox.txt", "A")
)
);
using (var solution = project.Generate().ToVs()) {
mover(
solution,
solution.WaitForItem("DragDropCopyCutPaste", "B"),
solution.WaitForItem("DragDropCopyCutPaste", "A", "quox.txt"),
solution.WaitForItem("DragDropCopyCutPaste", "quox.txt")
);
using (var dialog = solution.WaitForOverwriteFileDialog()) {
AssertUtil.Contains(dialog.Text, "A file with the same name 'quox.txt' already exists.");
dialog.Yes();
}
solution.AssertFileExists("DragDropCopyCutPaste", "B", "quox.txt");
solution.AssertFileDoesntExist("DragDropCopyCutPaste", "quox.txt");
solution.AssertFileDoesntExist("DragDropCopyCutPaste", "A", "quox.txt");
Assert.AreEqual(1, solution.GetProject("DragDropCopyCutPaste").ProjectItems.Item("B").ProjectItems.Count);
}
}
}
示例7: DragToAnotherProject
/// <summary>
/// Copy from CSharp into our project
/// </summary>
private void DragToAnotherProject(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var projects = new[] {
new ProjectDefinition(
"DragDropCopyCutPaste",
projectType,
ItemGroup(
Folder("!Source"),
Compile("!Source\\DraggedToOtherProject")
)
),
new ProjectDefinition(
"ConsoleApplication1",
ProjectType.CSharp,
ItemGroup(
Folder("DraggedToOtherProject")
)
)
};
using (var solution = SolutionFile.Generate("DragDropCopyCutPaste", projects).ToVs()) {
mover(
solution.WaitForItem("ConsoleApplication1"),
solution.WaitForItem("DragDropCopyCutPaste", "!Source", "DraggedToOtherProject" + projectType.CodeExtension)
);
solution.AssertFileExists("ConsoleApplication1", "DraggedToOtherProject" + projectType.CodeExtension);
solution.AssertFileExists("DragDropCopyCutPaste", "!Source", "DraggedToOtherProject" + projectType.CodeExtension);
}
}
}
示例8: MoveReverseCrossHierarchy
/// <summary>
/// Cut an item from our project, paste into another project, item should be removed from our project
/// </summary>
private void MoveReverseCrossHierarchy(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var projects = new[] {
new ProjectDefinition(
"DragDropCopyCutPaste",
projectType,
ItemGroup(
Compile("CrossHierarchyCut")
)
),
new ProjectDefinition(
"ConsoleApplication1",
ProjectType.CSharp
)
};
using (var solution = SolutionFile.Generate("DragDropCopyCutPaste", projects).ToVs()) {
mover(
solution,
solution.WaitForItem("ConsoleApplication1"),
solution.WaitForItem("DragDropCopyCutPaste", "CrossHierarchyCut" + projectType.CodeExtension)
);
solution.AssertFileExists("ConsoleApplication1", "CrossHierarchyCut" + projectType.CodeExtension);
solution.AssertFileDoesntExist("DragDropCopyCutPaste", "CrossHierarchyCut" + projectType.CodeExtension);
}
}
}
示例9: MoveCrossHierarchy
/// <summary>
/// Cut item from one project, paste into another project, item should be removed from original project
/// </summary>
private void MoveCrossHierarchy(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var projects = new[] {
new ProjectDefinition(
"DragDropCopyCutPaste",
projectType,
ItemGroup(
Folder("!Source"),
Compile("!Source\\DraggedToOtherProject")
)
),
new ProjectDefinition(
"ConsoleApplication1",
ProjectType.CSharp,
ItemGroup(
Compile("CrossHierarchyCut")
)
)
};
using (var solution = SolutionFile.Generate("DragDropCopyCutPaste", projects).ToVs()) {
mover(
solution,
solution.WaitForItem("DragDropCopyCutPaste"),
solution.WaitForItem("ConsoleApplication1", "CrossHierarchyCut.cs")
);
solution.AssertFileExists("DragDropCopyCutPaste", "CrossHierarchyCut.cs");
solution.AssertFileDoesntExist("ConsoleApplication1", "CrossHierarchyCut.cs");
}
}
}
示例10: MoveDuplicateFileNameSkipMove
/// <summary>
/// Move item within the project from one location to where it already exists, skipping the move.
/// </summary>
private void MoveDuplicateFileNameSkipMove(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var testDef = new ProjectDefinition("MoveDuplicateFileName",
projectType,
ItemGroup(
Folder("Folder"),
Content("textfile.txt", "root"),
Content("Folder\\textfile.txt", "Folder")
)
);
using (var solution = testDef.Generate().ToVs()) {
mover(
solution.FindItem("MoveDuplicateFileName", "Folder"),
solution.FindItem("MoveDuplicateFileName", "textfile.txt")
);
using (var dialog = OverwriteFileDialog.Wait(solution.App)) {
dialog.No();
}
solution.App.WaitForDialogDismissed();
solution.AssertFileExistsWithContent("root", "MoveDuplicateFileName", "textfile.txt");
solution.AssertFileExistsWithContent("Folder", "MoveDuplicateFileName", "Folder", "textfile.txt");
}
}
}
示例11: CutFileToFolderTooLong
/// <summary>
/// Adds a new folder which fits exactly w/ no space left in the path name
/// </summary>
private void CutFileToFolderTooLong(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var testDef = new ProjectDefinition("LFN",
projectType,
ItemGroup(
Compile("server")
)
);
using (var solution = SolutionFile.Generate("LongFileNames", 29, testDef).ToVs()) {
// find server, send copy & paste, verify copy of file is there
var projectNode = solution.WaitForItem("LFN");
AutomationWrapper.Select(projectNode);
solution.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift);
solution.PressAndRelease(Key.D);
solution.PressAndRelease(Key.Right);
solution.PressAndRelease(Key.D);
solution.Type("01234567891");
solution.PressAndRelease(Key.Enter);
var folderNode = solution.WaitForItem("LFN", "01234567891");
Assert.IsNotNull(folderNode);
var serverNode = solution.FindItem("LFN", "server" + projectType.CodeExtension);
AutomationWrapper.Select(serverNode);
solution.ControlC();
solution.ControlV();
var serverCopy = solution.WaitForItem("LFN", "server - Copy" + projectType.CodeExtension);
Assert.IsNotNull(serverCopy);
mover(solution, folderNode, serverCopy);
// Depending on VS version/update, the message may be:
// "The filename is too long."
// "The filename or extension is too long."
solution.CheckMessageBox(" filename ", " is too long.");
}
}
}
示例12: MoveFileFromFolderToLinkedFolder
/// <summary>
/// Move item to a folder that has a symbolic link. Verify we cannot move
/// ourselves to ourselves and that moves are reflected in both the folder and its symbolic link.
/// NOTE: Because of symbolic link creation, this test must be run as administrator.
/// </summary>
private void MoveFileFromFolderToLinkedFolder(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var projectDefs = new[] {
new ProjectDefinition("MoveLinkedFolder",
projectType,
ItemGroup(
Content("textfile.txt", "text file contents"),
Folder("Folder"),
Content("Folder\\FileInFolder.txt", "File inside of linked folder..."),
SymbolicLink("FolderLink", "Folder")
)
)
};
using (var solution = SolutionFile.Generate("MoveLinkedFolder", projectDefs).ToVs()) {
mover(
solution,
solution.FindItem("MoveLinkedFolder", "FolderLink"),
solution.FindItem("MoveLinkedFolder", "Folder", "FileInFolder.txt")
);
// Say okay to the error that pops up since we can't move to ourselves.
solution.WaitForDialog();
Keyboard.Type(Key.Enter);
solution.WaitForDialogDismissed();
// Verify that after the dialog our files are still present.
solution.AssertFileExists("MoveLinkedFolder", "FolderLink", "FileInFolder.txt");
solution.AssertFileExists("MoveLinkedFolder", "Folder", "FileInFolder.txt");
// Now move the text file in the root. Expect it to move and be in both.
mover(
solution,
solution.FindItem("MoveLinkedFolder", "FolderLink"),
solution.FindItem("MoveLinkedFolder", "textfile.txt")
);
solution.AssertFileExists("MoveLinkedFolder", "FolderLink", "textfile.txt");
solution.AssertFileExists("MoveLinkedFolder", "Folder", "textfile.txt");
}
}
}
示例13: CopyFileFromFolderToLinkedFolder
/// <summary>
/// Copy item from folder to a symbolic link of that folder. Expect a copy to be made.
/// NOTE: Because of symbolic link creation, this test must be run as administrator.
/// </summary>
private void CopyFileFromFolderToLinkedFolder(MoveDelegate copier) {
foreach (var projectType in ProjectTypes) {
var projectDefs = new[] {
new ProjectDefinition("MoveLinkedFolder",
projectType,
ItemGroup(
Folder("Folder"),
Content("Folder\\FileInFolder.txt", "File inside of linked folder..."),
SymbolicLink("FolderLink", "Folder")
)
)
};
using (var solution = SolutionFile.Generate("MoveLinkedFolder", projectDefs).ToVs()) {
copier(
solution,
solution.FindItem("MoveLinkedFolder", "FolderLink"),
solution.FindItem("MoveLinkedFolder", "Folder", "FileInFolder.txt"));
// Verify that after the dialog our files are still present.
solution.AssertFileExists("MoveLinkedFolder", "FolderLink", "FileInFolder.txt");
solution.AssertFileExists("MoveLinkedFolder", "Folder", "FileInFolder.txt");
// Verify the copies were made.
solution.AssertFileExists("MoveLinkedFolder", "FolderLink", "FileInFolder - Copy.txt");
solution.AssertFileExists("MoveLinkedFolder", "Folder", "FileInFolder - Copy.txt");
}
}
}
示例14: CopyReadOnlyFile
private void CopyReadOnlyFile(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var projects = new[] {
new ProjectDefinition(
"CopyReadOnlyFile",
projectType,
ItemGroup(
Compile("Class")
)
)
};
using (var solution = SolutionFile.Generate("CopyReadOnlyFile", projects).ToVs()) {
var classFile = Path.Combine(solution.SolutionDirectory, "CopyReadOnlyFile", "Class" + projectType.CodeExtension);
Assert.IsTrue(File.Exists(classFile));
File.SetAttributes(classFile, FileAttributes.ReadOnly | FileAttributes.Archive);
Assert.IsTrue(File.GetAttributes(classFile).HasFlag(FileAttributes.ReadOnly));
Assert.IsTrue(File.GetAttributes(classFile).HasFlag(FileAttributes.Archive));
var classCopyFile = Path.Combine(solution.SolutionDirectory, "CopyReadOnlyFile", "Class - Copy" + projectType.CodeExtension);
Assert.IsFalse(File.Exists(classCopyFile));
mover(
solution,
solution.WaitForItem("CopyReadOnlyFile"),
solution.WaitForItem("CopyReadOnlyFile", "Class" + projectType.CodeExtension)
);
solution.WaitForItem("CopyReadOnlyFile", "Class - Copy" + projectType.CodeExtension);
Assert.IsTrue(File.Exists(classCopyFile));
Assert.IsFalse(File.GetAttributes(classCopyFile).HasFlag(FileAttributes.ReadOnly), "Read-only attribute was not cleared");
Assert.IsTrue(File.GetAttributes(classCopyFile).HasFlag(FileAttributes.Archive), "Other attributes were cleared");
}
}
}
示例15: MoveProjectToSolutionFolder
/// <summary>
/// Cut an item from our project, paste into another project, item should be removed from our project
/// </summary>
private void MoveProjectToSolutionFolder(MoveDelegate mover) {
foreach (var projectType in ProjectTypes) {
var projects = new ISolutionElement[] {
new ProjectDefinition("DragDropCopyCutPaste", projectType),
SolutionFolder("SolFolder")
};
using (var solution = SolutionFile.Generate("DragDropCopyCutPaste", projects).ToVs()) {
mover(
solution,
solution.WaitForItem("SolFolder"),
solution.WaitForItem("DragDropCopyCutPaste")
);
Assert.IsNotNull(solution.WaitForItem("SolFolder", "DragDropCopyCutPaste"));
}
}
}