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); } } }
/// <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, solution.FindItem("MoveDuplicateFileName", "Folder"), solution.FindItem("MoveDuplicateFileName", "textfile.txt") ); using (var dialog = solution.WaitForOverwriteFileDialog()) { dialog.No(); } solution.WaitForDialogDismissed(); solution.AssertFileExistsWithContent("root", "MoveDuplicateFileName", "textfile.txt"); solution.AssertFileExistsWithContent("Folder", "MoveDuplicateFileName", "Folder", "textfile.txt"); } } }
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"); } } }
public void SetWaveType(int waveTypeIndex) { switch (waveTypeIndex) { case 0: case 1: movePattern = MovePatterns.WavyX; break; case 2: movePattern = MovePatterns.Circular; break; case 3: // if our initial spawn position is on the left of the screen, we move right and vice versa if (transform.position.x < 0) { movePattern = MovePatterns.WavyYLeft; } else { movePattern = MovePatterns.WavyYRight; } break; } }
public void Idle(RaycastHit2D hit) { if (hit.collider.tag == "Player") { moveDelegate = new MoveDelegate(ChasePlayer); return; } bool closeToTarget = Vector2.Distance(transform.position, targetPosition) < .1f; float speed; if (meandering) { speed = .15f; if (closeToTarget) { targetPosition.x += Random.Range(-.25f, .2f); } } else { speed = .3f; targetPosition = startPosition; if (closeToTarget) { meandering = true; } } MoveToTargetClamped(speed); }
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); } } }
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"); } } }
public override void CompleteInteract() { base.CompleteInteract(); if (StoryOver && !AcquireSword) { MoveDelegate?.Invoke(this, new Point(6, 3)); } }
// Use this for initialization void Awake() { Instance = this; _mTransform = transform; moveEnd = OnMoveEnd; moveStart = OnMoveStart; }
// Use this for initialization void Awake() { Instance = this; _mTransform = transform; moveEnd = OnMoveEnd; moveStart = OnMoveStart; }
private void OnPlayerMoveFinished(int rowIndex, int columnIndex, DiscColor color) { if (!this.Game.IsStopped) { MoveDelegate refreshControl = new MoveDelegate(this.RefreshControl); this.Invoke(refreshControl, rowIndex, columnIndex, color); } }
public static void Move(MoveDelegate MakeDelegate) { IEnumerator <TargetUI> ie = staticStuffTargets.GetEnumerator(); while (ie.MoveNext()) { MakeDelegate(ie); } }
void Awake() { instance = this; m_selfTransform = this.transform; moveStart = OnMoveStart; moveEnd = OnMoveEnd; m_guiJoystackController = JoystickController.instance; }
/// <summary> /// Set the iterator to the specified element in the collection. /// </summary> /// <param name="index"> /// The zero-based index of the element to make current. /// </param> /// <returns> /// true if the iterator was successfully moved to the /// specified element; false if the index is out of range. /// </returns> public virtual bool MoveTo(int index) { if (index >= this.list.count || index < 0) { throw new IndexOutOfRangeException(); } this.node = this.head; // If the starting index is past the midpoint of the // list, walk the list from the back instead. if (index > (this.list.count / 2)) { index = (this.list.count - index) + 1; MovePointer = new MoveDelegate(MoveBackward); } else { MovePointer = new MoveDelegate(MoveForward); } // Walk the chain until the current node is just before // the node at index (or just after, if iterating backwards). // If index is 0, the current node is head and there's // no need to move the pointer. while (index > 0) { // MovePointer() returns false when the current node // is the head node. That indicates a corrupt list. if (!MovePointer()) { throw new IndexOutOfRangeException(); } --index; #region Assert Debug.Assert( node != null, "Null list reference", "A null reference was found in the list chain." ); #endregion } #region Assert // If this happens, the chain is corrupted. Debug.Assert( index >= 0, "Index out of range", "Index out of range" ); #endregion return(true); }
/// <summary> /// Creates a <see cref="CollectionChangedEventHandler{T}"/> from the specified delegates. /// </summary> /// <param name="add"> If null is specified, nothing is performed on addition of an element. </param> /// <param name="move"> If null is specified, nothing is performed on removal of an element. </param> /// <param name="remove"> If null is specified, nothing is performed on removal of an element. </param> /// <param name="replace"> If null is specified, the default action is performed, which is to first remove and then add the changes. </param> /// <param name="reset"> If null is specified, the default action is performed, which is to remove all elements. </param> public static CollectionChangedEventHandler <T> Create <TCollection>( AddDelegate <TCollection> add = null, RemoveDelegate <TCollection> remove = null, ReplaceDelegate <TCollection> replace = null, MoveDelegate <TCollection> move = null, ResetDelegate <TCollection> reset = null ) where TCollection : INotifyCollectionChanged { return(new DelegatedCollectionChangedEventHandler <TCollection>(move, add, reset, replace, remove)); }
//좌우 패트롤 protected override IEnumerator Move_Pattern_1() { Debug.Log("Move_Pattern_1"); int rndMoveType = Random.Range((int)Ease.Unset, (int)Ease.INTERNAL_Zero); int rndLoopCount = Random.Range(0, 4); moveDelegate = Move_Pattern_2; gameObject.transform.DOMove(new Vector2(0, 2), 5.0f).SetEase((Ease)rndMoveType).SetLoops(rndLoopCount, LoopType.Yoyo).OnComplete(() => { StartCoroutine(moveDelegate()); }); yield break; }
static void Main() { Action foo = Run; foo(); MoveDelegate run = RunAtSpeed; int result1 = run(5); MoveDelegate walk = WalkAtSpeed; int result2 = walk(1); }
public override void CompleteInteract() { if (_complete && !_moved && !AlreadyMoved) { var collision = _collision.Invoke(Position.ToPoint(), new Point(2, 20)); var endPoint = collision ? new Point(2, 22) : new Point(2, 20); MoveDelegate.Invoke(this, endPoint); _moved = true; } }
void Awake() { playerAnimation = GetComponent<Animation>(); playerAnimation["wait"].blendMode = AnimationBlendMode.Blend; instance = this; selfTransform = this.transform; moveStart = OnMoveStart; moveEnd = OnMoveEnd; }
// private Animation playerAnimation; void Awake() { // playerAnimation = GetComponent<Animation>(); // playerAnimation["wait"].blendMode = AnimationBlendMode.Blend; instance = this; selfTransform = this.transform; moveStart = OnMoveStart; moveEnd = OnMoveEnd; guiJoystackController = JoytackController.instance; }
void Awake() { context = new GameContext(); guiJoystackController = JoytackController.instance; GlobalClient.AddEventReceiver(EventType.EVT_MOUSE_FIRE1, context); GlobalClient.AddEventReceiver(EventType.EVT_MOUSE_FIRE2, context); context.MouseFire1Handler += OnMouseFire1; context.MouseFire2Handler += OnMouseFire2; moveStart = OnMoveStart; moveEnd = OnMoveEnd; }
// private Animation playerAnimation; void Awake() { // playerAnimation = GetComponent<Animation>(); // playerAnimation["wait"].blendMode = AnimationBlendMode.Blend; instance = this; selfTransform = this.transform; moveStart = OnMoveStart; moveEnd = OnMoveEnd; guiJoystackController = JoytackController.instance; }
/// <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 MoveDuplicateFileNamesCrossProjectSkipOne(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var projectDefs = new[] { new ProjectDefinition("MoveDuplicateFileName", projectType, ItemGroup( Content("textfile1.txt", "textfile1 - lang"), Content("textfile2.txt", "textfile2 - lang") ) ), new ProjectDefinition("MoveDuplicateFileName2", projectType, ItemGroup( Folder("Folder"), Content("textfile1.txt", "textfile1 - 2"), Content("textfile2.txt", "textfile2 - 2") ) ) }; using (var solution = SolutionFile.Generate("MoveDuplicateFileName", projectDefs).ToVs()) { var item1 = solution.FindItem("MoveDuplicateFileName", "textfile1.txt"); var item2 = solution.FindItem("MoveDuplicateFileName", "textfile2.txt"); mover( solution, solution.FindItem("MoveDuplicateFileName2"), item1, item2 ); using (var dialog = solution.WaitForOverwriteFileDialog()) { dialog.No(); } System.Threading.Thread.Sleep(1000); using (var dialog = solution.WaitForOverwriteFileDialog()) { dialog.Yes(); } solution.WaitForDialogDismissed(); solution.AssertFileExistsWithContent("textfile1 - lang", "MoveDuplicateFileName", "textfile1.txt"); solution.AssertFileExistsWithContent("textfile2 - lang", "MoveDuplicateFileName", "textfile2.txt"); solution.AssertFileExistsWithContent("textfile1 - 2", "MoveDuplicateFileName2", "textfile1.txt"); solution.AssertFileExistsWithContent("textfile2 - lang", "MoveDuplicateFileName2", "textfile2.txt"); } } }
/// <summary> /// Retourne une fonction de mouvement en vague dans la direction donnée, et de fréquence et d'amplitude donnée. /// La position de la vague ne dépend exclusivement que du temps de jeu. /// </summary> public static MoveDelegate MoveWaveUntemporal(Vector2 direction, float amplitude, float frequency) { MoveDelegate del = delegate(ParticleBase thisParticle, GameTime time) { TimeSpan end = time.TotalGameTime; Vector2 add = (direction * (float)Math.Sin(frequency * end.TotalSeconds) * amplitude); Vector2 pos = thisParticle.StartPosition + add; return(pos); }; return(del); }
void Awake() { rigidbody = GetComponent <Rigidbody2D>(); settingUp = true; moveLeft = MoveLeftNormal; moveRight = MoveRightNormal; currentControlType = ControlType.Normal; horizontalAxis = "Horizontal" + axisID; verticalAxis = "Vertical" + axisID; spriteRenderer = GetComponent <SpriteRenderer>(); type = CharacterTypeExtension.GetEnumFromID(tag); }
public void RunAway(RaycastHit2D hit) { switch (hit.collider.tag) { case "Wall": // Should they try to get back to where they were? moveDelegate = new MoveDelegate(Idle); return; } targetPosition = new Vector3(transform.position.x - (PlayerController.PlayerPosition - transform.position).normalized.x, transform.position.y, 0); MoveToTargetClamped(walkSpeed); }
/// <summary> /// Ends the move (asynchronous mode). /// </summary> /// <param name="ar">The ar.</param> public void EndMove(IAsyncResult ar) { MoveDelegate moveDelegate = ((System.Runtime.Remoting.Messaging.AsyncResult)ar).AsyncDelegate as MoveDelegate; if (moveDelegate != null) { moveDelegate.EndInvoke(ar); } else { throw new InvalidOperationException("cannot end invoke, asynchresult is null"); } }
public DelegatedCollectionChangedEventHandler( MoveDelegate <TCollection> move, AddDelegate <TCollection> add, ResetDelegate <TCollection> reset, ReplaceDelegate <TCollection> replace, RemoveDelegate <TCollection> remove ) { this.move = move; this.add = add; this.reset = reset; this.replace = replace; this.remove = remove; }
// End Movement Controllers // Changes movement and collision detection public void SetControlType(ControlType type) { currentControlType = type; if (type == ControlType.Normal) { moveLeft = MoveLeftNormal; moveRight = MoveRightNormal; } else if (type == ControlType.Inverted) { moveLeft = MoveRightNormal; moveRight = MoveLeftNormal; } }
/// <summary> /// Retourne une fonction de mouvement rectiligne crée à partir de la position de fin de la particule. /// </summary> /// <param name="endPos"></param> /// <returns></returns> public static MoveDelegate MoveLine(Vector2 endPos) { MoveDelegate del = delegate(ParticleBase thisParticle, GameTime time) { TimeSpan start = thisParticle.CreationTime.TotalGameTime; TimeSpan end = time.TotalGameTime; TimeSpan span = end - start; float percentLifetime = (float)span.TotalSeconds / thisParticle.DurationSeconds; Vector2 pos = thisParticle.StartPosition * (1 - percentLifetime) + endPos * percentLifetime; return(pos); }; return(del); }
/// <summary> /// Retourne une fonction de mouvement en vague dans la direction donnée, et de fréquence et d'amplitude donnée. /// </summary> public static MoveDelegate MoveWave(Vector2 direction, float amplitude, float frequency) { MoveDelegate del = delegate(ParticleBase thisParticle, GameTime time) { TimeSpan start = thisParticle.CreationTime.TotalGameTime; TimeSpan end = time.TotalGameTime; TimeSpan span = end - start; float percentLifetime = (float)span.TotalSeconds / thisParticle.DurationSeconds; Vector2 add = direction * (float)Math.Sin(frequency * percentLifetime) * amplitude; Vector2 pos = thisParticle.StartPosition + add; return(pos); }; return(del); }
/// <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"); } } }
/// <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(); } } }
/// <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"); } } }
private void Awake() { //Setup delegate methods = new MoveDelegate[3]; methods[0] = MoveArcade; move = methods[(int)movementStyle]; //Input setup ctrl = FPSManager.controls; ctrl.Gameplay.Enable(); ConfigureControlsDelegates(); cc = GetComponent <CharacterController>(); cam = Camera.main.gameObject; }
public StructArray(int length, ClearDelegate clearAction, MoveDelegate moveAction) { ClearAction = clearAction; MoveAction = moveAction; Length = length; Values = new T[length]; IdsToIndices = new int[length]; IndicesToIds = new int[length]; for (int i = 0; i < Length; i++) { Values[i] = new T(); IdsToIndices[i] = i; IndicesToIds[i] = i; } }
/// <summary> /// Cuts 3 files with the same name, pastes them to a folder, checks /// do this for all items, and makes sure all the files still exist somewhere. /// </summary> /// <param name="mover"></param> private void MoveDuplicateFileNameDontOverwriteAllItems(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var project = new ProjectDefinition( "DragDropCopyCutPaste", projectType, ItemGroup( Folder("A"), Folder("B"), Folder("C"), Content("quox.txt", "top-level"), Content("A\\quox.txt", "A"), Content("C\\quox.txt", "C") ) ); using (var solution = project.Generate().ToVs()) { mover( solution, solution.WaitForItem("DragDropCopyCutPaste", "B"), solution.WaitForItem("DragDropCopyCutPaste", "A", "quox.txt"), solution.WaitForItem("DragDropCopyCutPaste", "C", "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.AllItems = true; dialog.No(); } solution.WaitForDialogDismissed(); solution.AssertFileExists("DragDropCopyCutPaste", "B", "quox.txt"); int totalCount = solution.GetProject("DragDropCopyCutPaste").ProjectItems.Item("A").ProjectItems.Count + solution.GetProject("DragDropCopyCutPaste").ProjectItems.Item("B").ProjectItems.Count + solution.GetProject("DragDropCopyCutPaste").ProjectItems.Item("C").ProjectItems.Count + solution.GetProject("DragDropCopyCutPaste").ProjectItems.Cast<EnvDTE.ProjectItem>().Where(IsFile).Count(); Assert.AreEqual(3, totalCount); Assert.AreEqual(1, solution.GetProject("DragDropCopyCutPaste").ProjectItems.Item("B").ProjectItems.Count); } } }
/// <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); } } }
/// <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"); } } }
/// <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"); } } }
/// <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); } } }
/// <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 MoveDuplicateFileNamesCrossProjectSkipOne(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var projectDefs = new[] { new ProjectDefinition("MoveDuplicateFileName", projectType, ItemGroup( Content("textfile1.txt", "textfile1 - lang"), Content("textfile2.txt", "textfile2 - lang") ) ), new ProjectDefinition("MoveDuplicateFileName2", projectType, ItemGroup( Folder("Folder"), Content("textfile1.txt", "textfile1 - 2"), Content("textfile2.txt", "textfile2 - 2") ) ) }; using (var solution = SolutionFile.Generate("MoveDuplicateFileName", projectDefs).ToVs()) { var item1 = solution.FindItem("MoveDuplicateFileName", "textfile1.txt"); var item2 = solution.FindItem("MoveDuplicateFileName", "textfile2.txt"); mover( solution, solution.FindItem("MoveDuplicateFileName2"), item1, item2 ); using (var dialog = solution.WaitForOverwriteFileDialog()) { dialog.No(); } System.Threading.Thread.Sleep(1000); using (var dialog = solution.WaitForOverwriteFileDialog()) { dialog.Yes(); } solution.WaitForDialogDismissed(); solution.AssertFileExistsWithContent("textfile1 - lang", "MoveDuplicateFileName", "textfile1.txt"); solution.AssertFileExistsWithContent("textfile2 - lang", "MoveDuplicateFileName", "textfile2.txt"); solution.AssertFileExistsWithContent("textfile1 - 2", "MoveDuplicateFileName2", "textfile1.txt"); solution.AssertFileExistsWithContent("textfile2 - lang", "MoveDuplicateFileName2", "textfile2.txt"); } } }
/// <summary> /// Copy from C# into our project /// </summary> private void CrossHierarchyFileDragAndDrop(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var projects = new[] { new ProjectDefinition( "DragDropCopyCutPaste", projectType, ItemGroup( Folder("DropFolder") ) ), new ProjectDefinition( "ConsoleApplication1", ProjectType.CSharp, ItemGroup( Compile("CrossHierarchyFileDragAndDrop") ) ) }; using (var solution = SolutionFile.Generate("DragDropCopyCutPaste", projects).ToVs()) { mover( solution, solution.WaitForItem("DragDropCopyCutPaste", "DropFolder"), solution.WaitForItem("ConsoleApplication1", "CrossHierarchyFileDragAndDrop.cs") ); solution.AssertFileExists("DragDropCopyCutPaste", "DropFolder", "CrossHierarchyFileDragAndDrop.cs"); } } }
/// <summary> /// Drag file from another hierarchy into folder in our hierarchy, item should be added /// Cannot move the folder 'DuplicateFolderName'. A folder with that name already exists in the destination directory. /// </summary> private void MoveDuplicateFolderName(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("DragDropCopyCutPaste", projectType, ItemGroup( Folder("DuplicateFolderName"), Folder("DuplicateFolderNameTarget"), Folder("DuplicateFolderNameTarget\\DuplicateFolderName") ) ); using (var solution = testDef.Generate().ToVs()) { mover( solution, solution.WaitForItem("DragDropCopyCutPaste", "DuplicateFolderNameTarget"), solution.WaitForItem("DragDropCopyCutPaste", "DuplicateFolderName") ); solution.CheckMessageBox("Cannot move the folder 'DuplicateFolderName'. A folder with that name already exists in the destination directory."); } } }
// End Movement Controllers // Changes movement and collision detection public void SetControlType(ControlType type) { currentControlType = type; if (type == ControlType.Normal) { moveLeft = MoveLeftNormal; moveRight = MoveRightNormal; } else if (type == ControlType.Inverted) { moveLeft = MoveRightNormal; moveRight = MoveLeftNormal; } }
void Awake() { rigidbody = GetComponent<Rigidbody2D>(); settingUp = true; moveLeft = MoveLeftNormal; moveRight = MoveRightNormal; currentControlType = ControlType.Normal; horizontalAxis = "Horizontal" + axisID; verticalAxis = "Vertical" + axisID; spriteRenderer = GetComponent<SpriteRenderer>(); type = CharacterTypeExtension.GetEnumFromID(tag); }
/// <summary> /// Copy folder to a destination where the folder already exists. Say don't copy, nothing should be copied. /// </summary> private void CopyDuplicateFolderName(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("DragDropCopyCutPaste", projectType, ItemGroup( Folder("CopyDuplicateFolderName"), Compile("CopyDuplicateFolderName\\server"), Folder("CopyDuplicateFolderNameTarget"), Folder("CopyDuplicateFolderNameTarget\\CopyDuplicateFolderName") ) ); using (var solution = testDef.Generate().ToVs()) { mover( solution, solution.WaitForItem("DragDropCopyCutPaste", "CopyDuplicateFolderNameTarget"), solution.WaitForItem("DragDropCopyCutPaste", "CopyDuplicateFolderName") ); using (var dialog = solution.WaitForOverwriteFileDialog()) { AssertUtil.Contains(dialog.Text, "This folder already contains a folder called 'CopyDuplicateFolderName'"); dialog.No(); } solution.AssertFileDoesntExist("DragDropCopyCutPaste", "CopyDuplicateFolderNameTarget", "CopyDuplicateFolderName", "server" + projectType.CodeExtension); } } }
/// <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); } } }
/// <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."); } } }
/// <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"); } } }
/// <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"); } } }
/// <summary> /// Move item to where an item by that name exists across 2 projects of the same type. /// /// https://pytools.codeplex.com/workitem/1967 /// </summary> private void MoveDuplicateFileNameCrossProjectSkipMove(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var projectDefs = new[] { new ProjectDefinition("MoveDuplicateFileName1", projectType, ItemGroup( Content("textfile.txt", "MoveDuplicateFileName1") ) ), new ProjectDefinition("MoveDuplicateFileName2", projectType, ItemGroup( Folder("Folder"), Content("textfile.txt", "MoveDuplicateFileName2") ) ) }; using (var solution = SolutionFile.Generate("MoveDuplicateFileName", projectDefs).ToVs()) { mover( solution, solution.FindItem("MoveDuplicateFileName2"), solution.FindItem("MoveDuplicateFileName1", "textfile.txt") ); using (var dialog = solution.WaitForOverwriteFileDialog()) { dialog.No(); } solution.WaitForDialogDismissed(); solution.AssertFileExistsWithContent("MoveDuplicateFileName1", "MoveDuplicateFileName1", "textfile.txt"); solution.AssertFileExistsWithContent("MoveDuplicateFileName2", "MoveDuplicateFileName2", "textfile.txt"); } } }
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"); } } }
/// <summary> /// Move item to where item exists across project types. /// </summary> private void MoveDuplicateFileNameCrossProjectCSharpSkipMove(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var projectDefs = new[] { new ProjectDefinition("MoveDuplicateFileName1", projectType, ItemGroup( Content("textfile.txt", "MoveDuplicateFileName1") ) ), new ProjectDefinition("MoveDuplicateFileNameCS", ProjectType.CSharp, ItemGroup( Folder("Folder"), Content("textfile.txt", "MoveDuplicateFileNameCS") ) ) }; using (var solution = SolutionFile.Generate("MoveDuplicateFileName", projectDefs).ToVs()) { mover( solution, solution.FindItem("MoveDuplicateFileNameCS"), solution.FindItem("MoveDuplicateFileName1", "textfile.txt") ); // say no to replacing in the C# project system solution.WaitForDialog(); Keyboard.Type(Key.N); solution.WaitForDialogDismissed(); solution.AssertFileExistsWithContent("MoveDuplicateFileName1", "MoveDuplicateFileName1", "textfile.txt"); solution.AssertFileExistsWithContent("MoveDuplicateFileNameCS", "MoveDuplicateFileNameCS", "textfile.txt"); } } }
/// <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")); } } }
/// <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"); } } }
/// <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); } } }