public void TestConstructorThrowsXdkNotFoundExceptionXdkDirectoryIsNotSet() { string storeValue = Environment.GetEnvironmentVariable("DurangoXdk"); const string ExpectedXdkRegistryKeyName = "InstallPath"; Environment.SetEnvironmentVariable("DurangoXdk", null); ShimRegistryKey.AllInstances.GetValueString = (instance, xdkRegistryKeyName) => { Assert.IsTrue(ExpectedXdkRegistryKeyName.Equals(xdkRegistryKeyName, StringComparison.InvariantCultureIgnoreCase)); return(null); }; try { ShimXboxConsoleAdapterBase.ConstructorXboxXdkBase = null; // we need to run real (not shimmed) constructor this.adapter = this.CreateXboxConsoleAdapter(); } finally { Environment.SetEnvironmentVariable("DurangoXdk", storeValue); } Assert.Fail("The constructor must throw an exception when Durango XDK directory environment variable is not set."); }
public void TestInitialize() { this.shimsContext = ShimsContext.Create(); this.fakeXboxXdk = new FakeXboxXdk(); ShimXboxConsoleAdapterBase.ConstructorXboxXdkBase = (consoleAdapter, xboxXdk) => { var shimXboxConsoleAdapter = new ShimXboxConsoleAdapterBase(consoleAdapter) { XboxXdkGet = () => this.fakeXboxXdk, }; }; this.adapter = this.CreateXboxConsoleAdapter(); }
/// <summary> /// Determines whether a directory exists on an Xbox. /// </summary> /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param> /// <param name="path">The directory to look for.</param> /// <param name="consoleAdapter">The Xbox console to search on.</param> /// <returns>A value indicating whether the directory exists on the console or not.</returns> internal static bool ExistsImpl(string systemIpAddress, XboxPath path, XboxConsoleAdapterBase consoleAdapter) { return(XboxFileSystemInfo.ExistsImpl(systemIpAddress, path, xboxFileSystemInfoDefinition => xboxFileSystemInfoDefinition.IsDirectory, consoleAdapter)); }
/// <summary> /// Determines whether a file or directory exists on an Xbox. /// </summary> /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param> /// <param name="path">The file or directory to look for.</param> /// <param name="additionalExistsPredicate">The optional additional logic to determine existence based on XboxFileSystemInfoDefinition.</param> /// <param name="consoleAdapter">The Xbox console to search on.</param> /// <returns>A value indicating whether the file or directory exists on the console or not.</returns> internal static bool ExistsImpl(string systemIpAddress, XboxPath path, Func <XboxFileSystemInfoDefinition, bool> additionalExistsPredicate, XboxConsoleAdapterBase consoleAdapter) { XboxFileSystemInfoDefinition definition; try { definition = consoleAdapter.GetFileSystemInfoDefinition(systemIpAddress, path); } catch (FileNotFoundException) { return(false); } catch (UnauthorizedAccessException) { // Following the same approach as in .NET, returning false without throwing an exception in case of insufficient permissions: // http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx return(false); } if (additionalExistsPredicate != null) { return(additionalExistsPredicate(definition)); } return(true); }