Loading WindowsDevicePortalWrapper/TestAppXbox/Operations/SettingOperation.cs +3 −1 Original line number Diff line number Diff line Loading @@ -66,8 +66,10 @@ namespace TestApp setting.Name = desiredSetting; setting.Value = desiredValue; Task setSettingTask = portal.UpdateXboxSetting(setting); Task<XboxSetting> setSettingTask = portal.UpdateXboxSetting(setting); setSettingTask.Wait(); Console.WriteLine(setSettingTask.Result); } } } Loading WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestDelete.cs +21 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ //---------------------------------------------------------------------------------------------- using System; using System.IO; using System.Net.Http; using System.Threading.Tasks; using Microsoft.Tools.WindowsDevicePortal.Tests; Loading @@ -21,8 +22,10 @@ namespace Microsoft.Tools.WindowsDevicePortal /// </summary> /// <param name="uri">The uri to which the delete request will be issued.</param> /// <returns>Task tracking HTTP completion</returns> private async Task Delete(Uri uri) private async Task<Stream> Delete(Uri uri) { MemoryStream dataStream = null; WebRequestHandler requestSettings = new WebRequestHandler(); requestSettings.UseDefaultCredentials = false; requestSettings.Credentials = this.deviceConnection.Credentials; Loading @@ -42,8 +45,25 @@ namespace Microsoft.Tools.WindowsDevicePortal { throw new DevicePortalException(response); } if (response.Content != null) { using (HttpContent content = response.Content) { dataStream = new MemoryStream(); Task copyTask = content.CopyToAsync(dataStream); await copyTask.ConfigureAwait(false); copyTask.Wait(); // Ensure we return with the stream pointed at the origin. dataStream.Position = 0; } } } } return dataStream; } } } WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPost.cs +21 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ //---------------------------------------------------------------------------------------------- using System; using System.IO; using System.Net.Http; using System.Threading.Tasks; using Microsoft.Tools.WindowsDevicePortal.Tests; Loading @@ -21,8 +22,10 @@ namespace Microsoft.Tools.WindowsDevicePortal /// </summary> /// <param name="uri">The uri to which the post request will be issued.</param> /// <returns>Task tracking the completion of the POST request</returns> private async Task Post(Uri uri) private async Task<Stream> Post(Uri uri) { MemoryStream dataStream = null; WebRequestHandler requestSettings = new WebRequestHandler(); requestSettings.UseDefaultCredentials = false; requestSettings.Credentials = this.deviceConnection.Credentials; Loading @@ -42,8 +45,25 @@ namespace Microsoft.Tools.WindowsDevicePortal { throw new DevicePortalException(response); } if (response.Content != null) { using (HttpContent content = response.Content) { dataStream = new MemoryStream(); Task copyTask = content.CopyToAsync(dataStream); await copyTask.ConfigureAwait(false); copyTask.Wait(); // Ensure we return with the stream pointed at the origin. dataStream.Position = 0; } } } } return dataStream; } } } WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPut.cs +21 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ //---------------------------------------------------------------------------------------------- using System; using System.IO; using System.Net.Http; using System.Threading.Tasks; using Microsoft.Tools.WindowsDevicePortal.Tests; Loading @@ -22,10 +23,12 @@ namespace Microsoft.Tools.WindowsDevicePortal /// <param name="uri">The uri to which the put request will be issued.</param> /// <param name="body">The HTTP content comprising the body of the request.</param> /// <returns>Task tracking the PUT completion.</returns> private async Task Put( private async Task<Stream> Put( Uri uri, HttpContent body = null) { MemoryStream dataStream = null; WebRequestHandler requestSettings = new WebRequestHandler(); requestSettings.UseDefaultCredentials = false; requestSettings.Credentials = this.deviceConnection.Credentials; Loading @@ -46,8 +49,25 @@ namespace Microsoft.Tools.WindowsDevicePortal { throw new DevicePortalException(response); } if (response.Content != null) { using (HttpContent content = response.Content) { dataStream = new MemoryStream(); Task copyTask = content.CopyToAsync(dataStream); await copyTask.ConfigureAwait(false); copyTask.Wait(); // Ensure we return with the stream pointed at the origin. dataStream.Position = 0; } } } } return dataStream; } } } WindowsDevicePortalWrapper/UnitTestProject/Xbox/XboxSettingsTests.cs +13 −3 Original line number Diff line number Diff line Loading @@ -94,10 +94,20 @@ namespace Microsoft.Tools.WindowsDevicePortal.Tests HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NoContent); TestHelpers.MockHttpResponder.AddMockResponse(Path.Combine(DevicePortal.XboxSettingsApi, setting.Name)); Task udpateSettingsTask = TestHelpers.Portal.UpdateXboxSetting(setting); udpateSettingsTask.Wait(); Task<XboxSetting> updateSettingsTask = TestHelpers.Portal.UpdateXboxSetting(setting); updateSettingsTask.Wait(); Assert.AreEqual(TaskStatus.RanToCompletion, udpateSettingsTask.Status); Assert.AreEqual(TaskStatus.RanToCompletion, updateSettingsTask.Status); XboxSetting recievedSetting = updateSettingsTask.Result; // Check some known things about this response. Assert.AreEqual(setting.Name, recievedSetting.Name); // Note this is still 720p because that's what our default mock returns. Assert.AreEqual("720p", recievedSetting.Value); Assert.AreEqual("Video", recievedSetting.Category); Assert.AreEqual("No", recievedSetting.RequiresReboot); } } } Loading
WindowsDevicePortalWrapper/TestAppXbox/Operations/SettingOperation.cs +3 −1 Original line number Diff line number Diff line Loading @@ -66,8 +66,10 @@ namespace TestApp setting.Name = desiredSetting; setting.Value = desiredValue; Task setSettingTask = portal.UpdateXboxSetting(setting); Task<XboxSetting> setSettingTask = portal.UpdateXboxSetting(setting); setSettingTask.Wait(); Console.WriteLine(setSettingTask.Result); } } } Loading
WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestDelete.cs +21 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ //---------------------------------------------------------------------------------------------- using System; using System.IO; using System.Net.Http; using System.Threading.Tasks; using Microsoft.Tools.WindowsDevicePortal.Tests; Loading @@ -21,8 +22,10 @@ namespace Microsoft.Tools.WindowsDevicePortal /// </summary> /// <param name="uri">The uri to which the delete request will be issued.</param> /// <returns>Task tracking HTTP completion</returns> private async Task Delete(Uri uri) private async Task<Stream> Delete(Uri uri) { MemoryStream dataStream = null; WebRequestHandler requestSettings = new WebRequestHandler(); requestSettings.UseDefaultCredentials = false; requestSettings.Credentials = this.deviceConnection.Credentials; Loading @@ -42,8 +45,25 @@ namespace Microsoft.Tools.WindowsDevicePortal { throw new DevicePortalException(response); } if (response.Content != null) { using (HttpContent content = response.Content) { dataStream = new MemoryStream(); Task copyTask = content.CopyToAsync(dataStream); await copyTask.ConfigureAwait(false); copyTask.Wait(); // Ensure we return with the stream pointed at the origin. dataStream.Position = 0; } } } } return dataStream; } } }
WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPost.cs +21 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ //---------------------------------------------------------------------------------------------- using System; using System.IO; using System.Net.Http; using System.Threading.Tasks; using Microsoft.Tools.WindowsDevicePortal.Tests; Loading @@ -21,8 +22,10 @@ namespace Microsoft.Tools.WindowsDevicePortal /// </summary> /// <param name="uri">The uri to which the post request will be issued.</param> /// <returns>Task tracking the completion of the POST request</returns> private async Task Post(Uri uri) private async Task<Stream> Post(Uri uri) { MemoryStream dataStream = null; WebRequestHandler requestSettings = new WebRequestHandler(); requestSettings.UseDefaultCredentials = false; requestSettings.Credentials = this.deviceConnection.Credentials; Loading @@ -42,8 +45,25 @@ namespace Microsoft.Tools.WindowsDevicePortal { throw new DevicePortalException(response); } if (response.Content != null) { using (HttpContent content = response.Content) { dataStream = new MemoryStream(); Task copyTask = content.CopyToAsync(dataStream); await copyTask.ConfigureAwait(false); copyTask.Wait(); // Ensure we return with the stream pointed at the origin. dataStream.Position = 0; } } } } return dataStream; } } }
WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPut.cs +21 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ //---------------------------------------------------------------------------------------------- using System; using System.IO; using System.Net.Http; using System.Threading.Tasks; using Microsoft.Tools.WindowsDevicePortal.Tests; Loading @@ -22,10 +23,12 @@ namespace Microsoft.Tools.WindowsDevicePortal /// <param name="uri">The uri to which the put request will be issued.</param> /// <param name="body">The HTTP content comprising the body of the request.</param> /// <returns>Task tracking the PUT completion.</returns> private async Task Put( private async Task<Stream> Put( Uri uri, HttpContent body = null) { MemoryStream dataStream = null; WebRequestHandler requestSettings = new WebRequestHandler(); requestSettings.UseDefaultCredentials = false; requestSettings.Credentials = this.deviceConnection.Credentials; Loading @@ -46,8 +49,25 @@ namespace Microsoft.Tools.WindowsDevicePortal { throw new DevicePortalException(response); } if (response.Content != null) { using (HttpContent content = response.Content) { dataStream = new MemoryStream(); Task copyTask = content.CopyToAsync(dataStream); await copyTask.ConfigureAwait(false); copyTask.Wait(); // Ensure we return with the stream pointed at the origin. dataStream.Position = 0; } } } } return dataStream; } } }
WindowsDevicePortalWrapper/UnitTestProject/Xbox/XboxSettingsTests.cs +13 −3 Original line number Diff line number Diff line Loading @@ -94,10 +94,20 @@ namespace Microsoft.Tools.WindowsDevicePortal.Tests HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.NoContent); TestHelpers.MockHttpResponder.AddMockResponse(Path.Combine(DevicePortal.XboxSettingsApi, setting.Name)); Task udpateSettingsTask = TestHelpers.Portal.UpdateXboxSetting(setting); udpateSettingsTask.Wait(); Task<XboxSetting> updateSettingsTask = TestHelpers.Portal.UpdateXboxSetting(setting); updateSettingsTask.Wait(); Assert.AreEqual(TaskStatus.RanToCompletion, udpateSettingsTask.Status); Assert.AreEqual(TaskStatus.RanToCompletion, updateSettingsTask.Status); XboxSetting recievedSetting = updateSettingsTask.Result; // Check some known things about this response. Assert.AreEqual(setting.Name, recievedSetting.Name); // Note this is still 720p because that's what our default mock returns. Assert.AreEqual("720p", recievedSetting.Value); Assert.AreEqual("Video", recievedSetting.Category); Assert.AreEqual("No", recievedSetting.RequiresReboot); } } }