/// <summary> /// Connects to the console and retrieves the collection of installed packages. /// </summary> /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param> /// <returns>The collection of packages installed on the console.</returns> protected override IEnumerable <XboxPackageDefinition> GetInstalledPackagesImpl(string systemIpAddress) { // In the November 2014 XDK the format of the string returned by the XDK is a JSON object with this schema: // {"Packages":[{"FullName":"Achievements_1.0.1308.7000_x64__8wekyb3d8bbwe","Applications":[{"Aumid":"Achievements_8wekyb3d8bbwe!App"}]}]} string xdkOutput = this.XboxXdk.GetInstalledPackages(systemIpAddress); List <XboxPackageDefinition> returnValue = new List <XboxPackageDefinition>(); InstalledPackages installedPackages; try { using (XmlDictionaryReader jsonReader = JsonReaderWriterFactory.CreateJsonReader(Encoding.Unicode.GetBytes(xdkOutput), XmlDictionaryReaderQuotas.Max)) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(InstalledPackages)); installedPackages = (InstalledPackages)serializer.ReadObject(jsonReader); } } catch (ArgumentNullException ex) { throw new XboxConsoleException("Failed to parse installed packages string.", ex); } catch (SerializationException ex) { throw new XboxConsoleException("Failed to parse installed packages string.", ex); } foreach (var package in installedPackages.Packages) { string packageFullName = package.FullName; XboxPackageDefinition newPackage = new XboxPackageDefinition(packageFullName, package.Applications.Select(app => app.Aumid)); returnValue.Add(newPackage); } return(returnValue); }
public void TestConstructorSetsPropertiesCorrectly() { XboxPackageDefinition package = new XboxPackageDefinition(PackageFullName, PackageFamilyName, Aumids); Assert.AreEqual(PackageFullName, package.FullName, "The FullName property was not set correctly."); Assert.AreEqual(PackageFamilyName, package.FamilyName, "The FamilyName property was not set correctly."); CollectionAssert.AreEquivalent(Aumids, package.ApplicationDefinitions.Select(x => x.Aumid).ToList(), "The Applications AumIds property was not set correctly."); CollectionAssert.AreEquivalent(new string[] { ApplicationId }, package.ApplicationDefinitions.Select(x => x.ApplicationId).ToList(), "The Applications ApplicationId property was not set correctly."); }
/// <summary> /// Sets debug mode for a package. /// </summary> /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param> /// <param name="package">The package to be set debug mode for.</param> /// <param name="enabled">The value indicating whether debug mode should be enabled or disabled.</param> protected override void SetDebugModeImpl(string systemIpAddress, XboxPackageDefinition package, bool enabled) { if (package == null) { throw new ArgumentNullException("package"); } this.XboxXdk.SetDebugMode(systemIpAddress, package.FullName, enabled); }
/// <summary> /// Unconstrains a constrained package. /// </summary> /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param> /// <param name="package">The package to be unconstrained.</param> protected override void UnconstrainPackageImpl(string systemIpAddress, XboxPackageDefinition package) { if (package == null) { throw new ArgumentNullException("package"); } this.XboxXdk.UnconstrainPackage(systemIpAddress, package.FullName); }
/// <summary> /// Uninstall a package from a given console based on its package full name. /// </summary> /// <param name="systemIpAddress">The IP address of the console to be affected.</param> /// <param name="package">The package to be uninstalled.</param> protected override void UninstallPackageImpl(string systemIpAddress, XboxPackageDefinition package) { if (string.IsNullOrWhiteSpace(systemIpAddress)) { throw new ArgumentNullException("systemIpAddress"); } if (package == null) { throw new ArgumentNullException("package"); } this.XboxXdk.UninstallPackage(systemIpAddress, package.FullName); }
public void TestInitialize() { this.shimsContext = ShimsContext.Create(); this.packageDefinition = new XboxPackageDefinition(PackageFullName, PackageFamilyName, Aumids); ShimXboxConsole.ConstructorIPAddress = (console, address) => { var myShim = new ShimXboxConsole(console) { AdapterGet = () => new StubXboxConsoleAdapterBase(null), SystemIpAddressGet = () => IPAddress.Parse(XboxPackageTests.ConsoleAddress), XboxGamepadsGet = () => new List <GamesTest.Xbox.Input.XboxGamepad>() }; }; ShimXboxConsoleAdapterBase.ConstructorXboxXdkBase = (adapter, xboxXdk) => { }; this.xboxConsole = new XboxConsole((IPAddress)null); this.xboxPackage = new XboxPackage(this.packageDefinition, this.xboxConsole); }
public void TestConstructorThrowsWithEmptyPackageFamilyName() { XboxPackageDefinition package = new XboxPackageDefinition(PackageFullName, string.Empty, Aumids); }
public void TestConstructorThrowsWithNullApplications() { XboxPackageDefinition package = new XboxPackageDefinition(PackageFullName, PackageFamilyName, null); }
public void TestConstructorThrowsWithNullPackageFamilyName() { XboxPackageDefinition package = new XboxPackageDefinition(PackageFullName, null, Aumids); }
/// <summary> /// Retrieves the execution state of the given package. /// </summary> /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param> /// <param name="package">The package for which the execution state shall be retrieved.</param> /// <returns>The current execution state of the package given by the <paramref name="package"/> parameter.</returns> /// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="package"/> parameter is null.</exception> /// <exception cref="XboxConsoleException">Thrown if the execution state value returned by the XDK does not match one of the expected values.</exception> protected override PackageExecutionState QueryPackageExecutionStateImpl(string systemIpAddress, XboxPackageDefinition package) { if (package == null) { throw new ArgumentNullException("package"); } uint xdkValue = this.comExceptionWhenConnectingHandler.CheckForCOMExceptionWhenConnecting(() => { return(this.XboxXdk.QueryPackageExecutionState(systemIpAddress, package.FullName)); }, systemIpAddress); // Interpretation of the following values comes from the XDK team's sources. // The following C++ header files: // // $\sdpublic\xbox\sra\internal\sdk\inc\appmodeltools.h // $\xbox\base\appmodel\appmodeltools\inc\appmodeltools.h // // define an enum containing constants we are using to distinguish package states: // // typedef enum { // AMT_PACKAGE_STATE_UNKNOWN, // AMT_PACKAGE_STATE_RUNNING, // AMT_PACKAGE_STATE_SUSPENDING, // AMT_PACKAGE_STATE_SUSPENDED, // AMT_PACKAGE_STATE_TERMINATED, // AMT_PACKAGE_STATE_CONSTRAINED, // } AMT_PACKAGE_STATE; switch (xdkValue) { case 0: return(PackageExecutionState.Unknown); case 1: return(PackageExecutionState.Running); case 2: return(PackageExecutionState.Suspending); case 3: return(PackageExecutionState.Suspended); case 4: return(PackageExecutionState.Terminated); case 5: return(PackageExecutionState.Constrained); default: throw new XboxConsoleException(string.Format(CultureInfo.InvariantCulture, "Unknown package execution state value of '{0}'", xdkValue)); } }