/// <summary> /// Compare with another instance of a shared folder or object. /// </summary> /// <param name="obj">another shared folder</param> /// <returns>true if the shared folders are identical</returns> public override bool Equals(object obj) { if (obj is VMWareSharedFolder) { VMWareSharedFolder sharedFolder = (VMWareSharedFolder)obj; return(sharedFolder._hostPath == _hostPath && sharedFolder._shareName == _shareName); } return(base.Equals(obj)); }
public void TestGetAddRemoveSharedFolders() { foreach (VMWareVirtualMachine virtualMachine in _test.PoweredVirtualMachines) { try { ConsoleOutput.WriteLine("Enabling shared folders ..."); virtualMachine.SharedFolders.Enabled = true; int count = virtualMachine.SharedFolders.Count; ConsoleOutput.WriteLine("Shared folders: {0}", count); // add a shared folder VMWareSharedFolder currentDirectory = new VMWareSharedFolder( Guid.NewGuid().ToString(), Environment.CurrentDirectory); virtualMachine.SharedFolders.Add(currentDirectory); Assert.AreEqual(count + 1, virtualMachine.SharedFolders.Count); foreach (VMWareSharedFolder sharedFolder in virtualMachine.SharedFolders) { ConsoleOutput.WriteLine("Shared folder: {0} ({1})", sharedFolder.ShareName, sharedFolder.HostPath); } // remove the shared folder virtualMachine.SharedFolders.Remove(currentDirectory); Assert.AreEqual(count, virtualMachine.SharedFolders.Count); } catch (VMWareException ex) { switch (ex.ErrorCode) { case Constants.VIX_E_NOT_SUPPORTED: Assert.Ignore("Shared folders not supported on this VMWare platform."); break; default: throw; } } } }