diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 021dd98d..2cf8f08f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -71,6 +71,17 @@ Address any review comments, force push to your topic branch, and post a comment
If the pull request review goes well, a project maintainer will merge your changes. Thank you for helping improve the Windows Device Portal Wrapper!
+# NuGet release and versioning
+
+**For maintainers**
+
+When creating a new NuGet and GitHub release, the following steps should be taken:
+1. Bump the version number as appropriate in master (after 1.0, WDP Wrapper will correctly use semver)
+2. Merge from Master to Release, with a PR appropriately named ("v1.2.3 release")
+3. Squash and merge commits, leaving major feature entries and fixes in the description.
+4. Compile release builds of the .NET and UWP libraries, sign them, and upload to NuGet
+5. Cut a new release on GitHub using the same version number ("v1.2.3") and attach the signed libraries to the release.
+6. Update code documentation.
# Updating code documentation
diff --git a/Samples/SampleWdpClient.UniversalWindows/MainPage.xaml.cs b/Samples/SampleWdpClient.UniversalWindows/MainPage.xaml.cs
index fca8e65a..ad8d8d3e 100644
--- a/Samples/SampleWdpClient.UniversalWindows/MainPage.xaml.cs
+++ b/Samples/SampleWdpClient.UniversalWindows/MainPage.xaml.cs
@@ -62,7 +62,7 @@ private void ClearOutput()
///
/// The caller of this method.
/// The arguments associated with this event.
- private void ConnectToDevice_Click(object sender, RoutedEventArgs e)
+ private async void ConnectToDevice_Click(object sender, RoutedEventArgs e)
{
this.EnableConnectionControls(false);
this.EnableDeviceControls(false);
@@ -78,61 +78,51 @@ private void ConnectToDevice_Click(object sender, RoutedEventArgs e)
this.password.Password));
StringBuilder sb = new StringBuilder();
- Task connectTask = new Task(
- async () =>
- {
- sb.Append(this.MarshalGetCommandOutput());
- sb.AppendLine("Connecting...");
- this.MarshalUpdateCommandOutput(sb.ToString());
- portal.ConnectionStatus += (portal, connectArgs) =>
- {
- if (connectArgs.Status == DeviceConnectionStatus.Connected)
- {
- sb.Append("Connected to: ");
- sb.AppendLine(portal.Address);
- sb.Append("OS version: ");
- sb.AppendLine(portal.OperatingSystemVersion);
- sb.Append("Device family: ");
- sb.AppendLine(portal.DeviceFamily);
- sb.Append("Platform: ");
- sb.AppendLine(String.Format("{0} ({1})",
- portal.PlatformName,
- portal.Platform.ToString()));
- }
- else if (connectArgs.Status == DeviceConnectionStatus.Failed)
- {
- sb.AppendLine("Failed to connect to the device.");
- sb.AppendLine(connectArgs.Message);
- }
- };
-
- try
- {
- // If the user wants to allow untrusted connections, make a call to GetRootDeviceCertificate
- // with acceptUntrustedCerts set to true. This will enable untrusted connections for the
- // remainder of this session.
- if (allowUntrusted)
- {
- this.certificate = await portal.GetRootDeviceCertificateAsync(true);
- }
- await portal.ConnectAsync(manualCertificate: this.certificate);
- }
- catch (Exception exception)
- {
- sb.AppendLine(exception.Message);
- }
- this.MarshalUpdateCommandOutput(sb.ToString());
- });
+ sb.Append(this.commandOutput.Text);
+ sb.AppendLine("Connecting...");
+ this.commandOutput.Text = sb.ToString();
+ portal.ConnectionStatus += (portal, connectArgs) =>
+ {
+ if (connectArgs.Status == DeviceConnectionStatus.Connected)
+ {
+ sb.Append("Connected to: ");
+ sb.AppendLine(portal.Address);
+ sb.Append("OS version: ");
+ sb.AppendLine(portal.OperatingSystemVersion);
+ sb.Append("Device family: ");
+ sb.AppendLine(portal.DeviceFamily);
+ sb.Append("Platform: ");
+ sb.AppendLine(String.Format("{0} ({1})",
+ portal.PlatformName,
+ portal.Platform.ToString()));
+ }
+ else if (connectArgs.Status == DeviceConnectionStatus.Failed)
+ {
+ sb.AppendLine("Failed to connect to the device.");
+ sb.AppendLine(connectArgs.Message);
+ }
+ };
- Task continuationTask = connectTask.ContinueWith(
- (t) =>
+ try
+ {
+ // If the user wants to allow untrusted connections, make a call to GetRootDeviceCertificate
+ // with acceptUntrustedCerts set to true. This will enable untrusted connections for the
+ // remainder of this session.
+ if (allowUntrusted)
{
- this.MarshalEnableDeviceControls(true);
- this.MarshalEnableConnectionControls(true);
- });
+ this.certificate = await portal.GetRootDeviceCertificateAsync(true);
+ }
+ await portal.ConnectAsync(manualCertificate: this.certificate);
+ }
+ catch (Exception exception)
+ {
+ sb.AppendLine(exception.Message);
+ }
- connectTask.Start();
+ this.commandOutput.Text = sb.ToString();
+ EnableDeviceControls(true);
+ EnableConnectionControls(true);
}
///
@@ -179,55 +169,45 @@ private void EnableDeviceControls(bool enable)
///
/// The caller of this method.
/// The arguments associated with this event.
- private void GetIPConfig_Click(object sender, RoutedEventArgs e)
+ private async void GetIPConfig_Click(object sender, RoutedEventArgs e)
{
this.ClearOutput();
this.EnableConnectionControls(false);
this.EnableDeviceControls(false);
StringBuilder sb = new StringBuilder();
- Task getTask = new Task(
- async () =>
- {
- sb.Append(this.MarshalGetCommandOutput());
- sb.AppendLine("Getting IP configuration...");
- this.MarshalUpdateCommandOutput(sb.ToString());
+ sb.Append(commandOutput.Text);
+ sb.AppendLine("Getting IP configuration...");
+ commandOutput.Text = sb.ToString();
- try
- {
- IpConfiguration ipconfig = await portal.GetIpConfigAsync();
-
- foreach (NetworkAdapterInfo adapterInfo in ipconfig.Adapters)
- {
- sb.Append(" ");
- sb.AppendLine(adapterInfo.Description);
- sb.Append(" MAC address :");
- sb.AppendLine(adapterInfo.MacAddress);
- foreach (IpAddressInfo address in adapterInfo.IpAddresses)
- {
- sb.Append(" IP address :");
- sb.AppendLine(address.Address);
- }
- sb.Append(" DHCP address :");
- sb.AppendLine(adapterInfo.Dhcp.Address.Address);
- }
- }
- catch (Exception ex)
- {
- sb.AppendLine("Failed to get IP config info.");
- sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
- }
- });
+ try
+ {
+ IpConfiguration ipconfig = await portal.GetIpConfigAsync();
- Task continuationTask = getTask.ContinueWith(
- (t) =>
+ foreach (NetworkAdapterInfo adapterInfo in ipconfig.Adapters)
{
- this.MarshalUpdateCommandOutput(sb.ToString());
- this.MarshalEnableDeviceControls(true);
- this.MarshalEnableConnectionControls(true);
- });
+ sb.Append(" ");
+ sb.AppendLine(adapterInfo.Description);
+ sb.Append(" MAC address :");
+ sb.AppendLine(adapterInfo.MacAddress);
+ foreach (IpAddressInfo address in adapterInfo.IpAddresses)
+ {
+ sb.Append(" IP address :");
+ sb.AppendLine(address.Address);
+ }
+ sb.Append(" DHCP address :");
+ sb.AppendLine(adapterInfo.Dhcp.Address.Address);
+ }
+ }
+ catch (Exception ex)
+ {
+ sb.AppendLine("Failed to get IP config info.");
+ sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
+ }
- getTask.Start();
+ commandOutput.Text = sb.ToString();
+ EnableDeviceControls(true);
+ EnableConnectionControls(true);
}
///
@@ -235,130 +215,57 @@ private void GetIPConfig_Click(object sender, RoutedEventArgs e)
///
/// The caller of this method.
/// The arguments associated with this event.
- private void GetWifiInfo_Click(object sender, RoutedEventArgs e)
+ private async void GetWifiInfo_Click(object sender, RoutedEventArgs e)
{
this.ClearOutput();
this.EnableConnectionControls(false);
this.EnableDeviceControls(false);
StringBuilder sb = new StringBuilder();
- Task getTask = new Task(
- async () =>
- {
- sb.Append(this.MarshalGetCommandOutput());
- sb.AppendLine("Getting WiFi interfaces and networks...");
- this.MarshalUpdateCommandOutput(sb.ToString());
-
- try
- {
- WifiInterfaces wifiInterfaces = await portal.GetWifiInterfacesAsync();
- sb.AppendLine("WiFi Interfaces:");
- foreach (WifiInterface wifiInterface in wifiInterfaces.Interfaces)
- {
- sb.Append(" ");
- sb.AppendLine(wifiInterface.Description);
- sb.Append(" GUID: ");
- sb.AppendLine(wifiInterface.Guid.ToString());
-
- WifiNetworks wifiNetworks = await portal.GetWifiNetworksAsync(wifiInterface.Guid);
- sb.AppendLine(" Networks:");
- foreach (WifiNetworkInfo network in wifiNetworks.AvailableNetworks)
- {
- sb.Append(" SSID: ");
- sb.AppendLine(network.Ssid);
- sb.Append(" Profile name: ");
- sb.AppendLine(network.ProfileName);
- sb.Append(" is connected: ");
- sb.AppendLine(network.IsConnected.ToString());
- sb.Append(" Channel: ");
- sb.AppendLine(network.Channel.ToString());
- sb.Append(" Authentication algorithm: ");
- sb.AppendLine(network.AuthenticationAlgorithm);
- sb.Append(" Signal quality: ");
- sb.AppendLine(network.SignalQuality.ToString());
- }
- };
- }
- catch (Exception ex)
- {
- sb.AppendLine("Failed to get WiFi info.");
- sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
- }
- });
-
- Task continuationTask = getTask.ContinueWith(
- (t) =>
- {
- this.MarshalUpdateCommandOutput(sb.ToString());
- this.MarshalEnableDeviceControls(true);
- this.MarshalEnableConnectionControls(true);
- });
- getTask.Start();
- }
-
- ///
- /// Executes the EnabledConnectionControls method on the UI thread.
- ///
- /// True to enable the controls, false to disable them.
- private void MarshalEnableConnectionControls(bool enable)
- {
- Task t = this.Dispatcher.RunAsync(
- CoreDispatcherPriority.Normal,
- () =>
- {
- this.EnableConnectionControls(enable);
- }).AsTask();
- t.Wait();
- }
+ sb.Append(commandOutput.Text);
+ sb.AppendLine("Getting WiFi interfaces and networks...");
+ commandOutput.Text = sb.ToString();
- ///
- /// Executes the EnabledDeviceControls method on the UI thread.
- ///
- /// True to enable the controls, false to disable them.
- private void MarshalEnableDeviceControls(bool enable)
- {
- Task t = this.Dispatcher.RunAsync(
- CoreDispatcherPriority.Normal,
- () =>
- {
- this.EnableDeviceControls(enable);
- }).AsTask();
- t.Wait();
- }
-
- ///
- /// Executes the fetching of the text displayed in the command output UI element on the UI thread.
- ///
- /// The contents of the command output UI element.
- private string MarshalGetCommandOutput()
- {
- string output = string.Empty;
-
- Task t = this.Dispatcher.RunAsync(
- CoreDispatcherPriority.Normal,
- () =>
+ try
+ {
+ WifiInterfaces wifiInterfaces = await portal.GetWifiInterfacesAsync();
+ sb.AppendLine("WiFi Interfaces:");
+ foreach (WifiInterface wifiInterface in wifiInterfaces.Interfaces)
{
- output = this.commandOutput.Text;
- }).AsTask();
- t.Wait();
-
- return output;
- }
+ sb.Append(" ");
+ sb.AppendLine(wifiInterface.Description);
+ sb.Append(" GUID: ");
+ sb.AppendLine(wifiInterface.Guid.ToString());
+
+ WifiNetworks wifiNetworks = await portal.GetWifiNetworksAsync(wifiInterface.Guid);
+ sb.AppendLine(" Networks:");
+ foreach (WifiNetworkInfo network in wifiNetworks.AvailableNetworks)
+ {
+ sb.Append(" SSID: ");
+ sb.AppendLine(network.Ssid);
+ sb.Append(" Profile name: ");
+ sb.AppendLine(network.ProfileName);
+ sb.Append(" is connected: ");
+ sb.AppendLine(network.IsConnected.ToString());
+ sb.Append(" Channel: ");
+ sb.AppendLine(network.Channel.ToString());
+ sb.Append(" Authentication algorithm: ");
+ sb.AppendLine(network.AuthenticationAlgorithm);
+ sb.Append(" Signal quality: ");
+ sb.AppendLine(network.SignalQuality.ToString());
+ }
+ };
+ }
+ catch (Exception ex)
+ {
+ sb.AppendLine("Failed to get WiFi info.");
+ sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
+ }
- ///
- /// Executes the update of the text displayed in the command output UI element ont he UI thread.
- ///
- /// The text to display in the command output UI element.
- private void MarshalUpdateCommandOutput(string output)
- {
- Task t = this.Dispatcher.RunAsync(
- CoreDispatcherPriority.Normal,
- () =>
- {
- this.commandOutput.Text = output;
- }).AsTask();
- t.Wait();
+ commandOutput.Text = sb.ToString();
+ EnableDeviceControls(true);
+ EnableConnectionControls(true);
}
///
@@ -376,7 +283,7 @@ private void Password_PasswordChanged(object sender, RoutedEventArgs e)
///
/// The caller of this method.
/// The arguments associated with this event.
- private void RebootDevice_Click(object sender, RoutedEventArgs e)
+ private async void RebootDevice_Click(object sender, RoutedEventArgs e)
{
bool reenableDeviceControls = false;
@@ -385,34 +292,25 @@ private void RebootDevice_Click(object sender, RoutedEventArgs e)
this.EnableDeviceControls(false);
StringBuilder sb = new StringBuilder();
- Task rebootTask = new Task(
- async () =>
- {
- sb.Append(this.MarshalGetCommandOutput());
- sb.AppendLine("Rebooting the device");
- this.MarshalUpdateCommandOutput(sb.ToString());
- try
- {
- await portal.RebootAsync();
- }
- catch (Exception ex)
- {
- sb.AppendLine("Failed to reboot the device.");
- sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
- reenableDeviceControls = true;
- }
- });
+ sb.Append(commandOutput.Text);
+ sb.AppendLine("Rebooting the device");
+ commandOutput.Text = sb.ToString();
- Task continuationTask = rebootTask.ContinueWith(
- (t) =>
- {
- this.MarshalUpdateCommandOutput(sb.ToString());
- this.MarshalEnableDeviceControls(reenableDeviceControls);
- this.MarshalEnableConnectionControls(true);
- });
+ try
+ {
+ await portal.RebootAsync();
+ }
+ catch (Exception ex)
+ {
+ sb.AppendLine("Failed to reboot the device.");
+ sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
+ reenableDeviceControls = true;
+ }
- rebootTask.Start();
+ commandOutput.Text = sb.ToString();
+ EnableDeviceControls(reenableDeviceControls);
+ EnableConnectionControls(true);
}
///
@@ -420,7 +318,7 @@ private void RebootDevice_Click(object sender, RoutedEventArgs e)
///
/// The caller of this method.
/// The arguments associated with this event.
- private void ShutdownDevice_Click(object sender, RoutedEventArgs e)
+ private async void ShutdownDevice_Click(object sender, RoutedEventArgs e)
{
bool reenableDeviceControls = false;
@@ -429,34 +327,23 @@ private void ShutdownDevice_Click(object sender, RoutedEventArgs e)
this.EnableDeviceControls(false);
StringBuilder sb = new StringBuilder();
- Task shutdownTask = new Task(
- async () =>
- {
- sb.Append(this.MarshalGetCommandOutput());
- sb.AppendLine("Shutting down the device");
- this.MarshalUpdateCommandOutput(sb.ToString());
-
- try
- {
- await portal.ShutdownAsync();
- }
- catch (Exception ex)
- {
- sb.AppendLine("Failed to shut down the device.");
- sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
- reenableDeviceControls = true;
- }
- });
-
- Task continuationTask = shutdownTask.ContinueWith(
- (t) =>
- {
- this.MarshalUpdateCommandOutput(sb.ToString());
- this.MarshalEnableDeviceControls(reenableDeviceControls);
- this.MarshalEnableConnectionControls(true);
- });
+ sb.Append(commandOutput.Text);
+ sb.AppendLine("Shutting down the device");
+ commandOutput.Text = sb.ToString();
+ try
+ {
+ await portal.ShutdownAsync();
+ }
+ catch (Exception ex)
+ {
+ sb.AppendLine("Failed to shut down the device.");
+ sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
+ reenableDeviceControls = true;
+ }
- shutdownTask.Start();
+ commandOutput.Text = sb.ToString();
+ EnableDeviceControls(reenableDeviceControls);
+ EnableConnectionControls(true);
}
///
diff --git a/WindowsDevicePortalWrapper/MockDataGenerator/Program.cs b/WindowsDevicePortalWrapper/MockDataGenerator/Program.cs
index fdf35088..a86be83a 100644
--- a/WindowsDevicePortalWrapper/MockDataGenerator/Program.cs
+++ b/WindowsDevicePortalWrapper/MockDataGenerator/Program.cs
@@ -40,8 +40,11 @@ public class Program
new Endpoint(HttpMethods.Get, DevicePortal.IpConfigApi),
new Endpoint(HttpMethods.Get, DevicePortal.SystemPerfApi),
new Endpoint(HttpMethods.Get, DevicePortal.RunningProcessApi),
+ new Endpoint(HttpMethods.Get, DevicePortal.CustomEtwProvidersApi),
+ new Endpoint(HttpMethods.Get, DevicePortal.EtwProvidersApi),
new Endpoint(HttpMethods.WebSocket, DevicePortal.SystemPerfApi),
new Endpoint(HttpMethods.WebSocket, DevicePortal.RunningProcessApi),
+ new Endpoint(HttpMethods.WebSocket, DevicePortal.RealtimeEtwSessionApi),
// HoloLens specific endpoints
new Endpoint(HttpMethods.Get, DevicePortal.HolographicIpdApi),
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/Core/EtwTests.cs b/WindowsDevicePortalWrapper/UnitTestProject/Core/EtwTests.cs
new file mode 100644
index 00000000..6774e3da
--- /dev/null
+++ b/WindowsDevicePortalWrapper/UnitTestProject/Core/EtwTests.cs
@@ -0,0 +1,109 @@
+//----------------------------------------------------------------------------------------------
+//
+// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
+//
+//----------------------------------------------------------------------------------------------
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using static Microsoft.Tools.WindowsDevicePortal.DevicePortal;
+
+namespace Microsoft.Tools.WindowsDevicePortal.Tests.Core
+{
+ ///
+ /// Test class for ETW APIs.
+ ///
+ [TestClass]
+ public class EtwTests : BaseTests
+ {
+ ///
+ /// Basic test of GET method for getting a list of custom registered ETW providers.
+ ///
+ [TestMethod]
+ public void GetCustomEtwProvidersTest()
+ {
+ TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.CustomEtwProvidersApi, HttpMethods.Get);
+
+ Task getCustomEtwProvidersTask = TestHelpers.Portal.GetCustomEtwProvidersAsync();
+ getCustomEtwProvidersTask.Wait();
+
+ Assert.AreEqual(TaskStatus.RanToCompletion, getCustomEtwProvidersTask.Status);
+
+ ValidateEtwProviders(getCustomEtwProvidersTask.Result);
+ }
+
+ ///
+ /// Basic test of GET method for getting a list of registered ETW providers.
+ ///
+ [TestMethod]
+ public void GetEtwProvidersTest()
+ {
+ TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.EtwProvidersApi, HttpMethods.Get);
+
+ Task getEtwProvidersTask = TestHelpers.Portal.GetEtwProvidersAsync();
+ getEtwProvidersTask.Wait();
+
+ Assert.AreEqual(TaskStatus.RanToCompletion, getEtwProvidersTask.Status);
+
+ ValidateEtwProviders(getEtwProvidersTask.Result);
+ }
+
+ [TestMethod]
+ public void GetEtwEventsTest()
+ {
+ TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.RealtimeEtwSessionApi, HttpMethods.WebSocket);
+
+ ManualResetEvent etwEventsReceived = new ManualResetEvent(false);
+ EtwEvents etwEvents = null;
+
+ WindowsDevicePortal.WebSocketMessageReceivedEventHandler etwEventsReceivedHandler =
+ delegate (DevicePortal sender, WebSocketMessageReceivedEventArgs args)
+ {
+ if (args.Message != null)
+ {
+ etwEvents = args.Message;
+ etwEventsReceived.Set();
+ }
+ };
+
+ TestHelpers.Portal.RealtimeEventsMessageReceived += etwEventsReceivedHandler;
+
+ Task startListeningForEtwEventsTask = TestHelpers.Portal.StartListeningForEtwEventsAsync();
+ startListeningForEtwEventsTask.Wait();
+ Assert.AreEqual(TaskStatus.RanToCompletion, startListeningForEtwEventsTask.Status);
+
+ etwEventsReceived.WaitOne();
+
+ Task stopListeningForEtwEventsTask = TestHelpers.Portal.StopListeningForEtwEventsAsync();
+ stopListeningForEtwEventsTask.Wait();
+ Assert.AreEqual(TaskStatus.RanToCompletion, stopListeningForEtwEventsTask.Status);
+
+ TestHelpers.Portal.RealtimeEventsMessageReceived -= etwEventsReceivedHandler;
+
+ ValidateEtwEvents(etwEvents);
+ }
+
+ ///
+ /// Validate the returned from the tests.
+ ///
+ /// The to validate.
+ private static void ValidateEtwEvents(EtwEvents etwEvents)
+ {
+ Assert.IsNotNull(etwEvents);
+ }
+
+ ///
+ /// Validate the returned from the tests.
+ ///
+ /// The to validate.
+ private static void ValidateEtwProviders(EtwProviders etw)
+ {
+ Assert.IsTrue(etw.Providers.Count > 0);
+ Assert.IsTrue(etw.Providers.All(etwProvider => !string.IsNullOrEmpty(etwProvider.Name)));
+ }
+ }
+}
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/Core/WindowsErrorReportingTests.cs b/WindowsDevicePortalWrapper/UnitTestProject/Core/WindowsErrorReportingTests.cs
new file mode 100644
index 00000000..9335c9c7
--- /dev/null
+++ b/WindowsDevicePortalWrapper/UnitTestProject/Core/WindowsErrorReportingTests.cs
@@ -0,0 +1,78 @@
+//----------------------------------------------------------------------------------------------
+//
+// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
+//
+//----------------------------------------------------------------------------------------------
+
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using static Microsoft.Tools.WindowsDevicePortal.DevicePortal;
+
+namespace Microsoft.Tools.WindowsDevicePortal.Tests.Core
+{
+ ///
+ /// Test class for Windows Error Reporting (WER) APIs.
+ ///
+ [TestClass]
+ public class WindowsErrorReportingTests : BaseTests
+ {
+ ///
+ /// Basic test of GET method for getting a list of Windows Error Reporting (WER) reports.
+ ///
+ [TestMethod]
+ public void GetWindowsErrorReportsTest()
+ {
+ TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.WindowsErrorReportsApi, HttpMethods.Get);
+
+ Task getWerReportsTask = TestHelpers.Portal.GetWindowsErrorReportsAsync();
+ getWerReportsTask.Wait();
+
+ Assert.AreEqual(TaskStatus.RanToCompletion, getWerReportsTask.Status);
+
+ List deviceReports = getWerReportsTask.Result.UserReports;
+ Assert.AreEqual(6, deviceReports.Count);
+ deviceReports.ForEach(userReport =>
+ {
+ Assert.IsFalse(string.IsNullOrWhiteSpace(userReport.UserName));
+ userReport.Reports.ForEach(report =>
+ {
+ Assert.AreNotEqual(0, report.CreationTime);
+ Assert.IsFalse(string.IsNullOrWhiteSpace(report.Name));
+ switch (report.Type.ToLower())
+ {
+ case "queue":
+ case "archive":
+ break;
+ default:
+ Assert.Fail($"Expected the report type to be 'Queue' or 'Archive'. Actual value is '{report.Type}'.");
+ break;
+ }
+ });
+ });
+ }
+
+ ///
+ /// Basic test of GET method for getting a list of Windows Error Reporting (WER) report files.
+ ///
+ [TestMethod]
+ public void GetWindowsErrorReportFilesTest()
+ {
+ TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.WindowsErrorReportingFilesApi, HttpMethods.Get);
+
+ Task getWerReportingFilesTask = TestHelpers.Portal.GetWindowsErrorReportingFileListAsync(string.Empty, string.Empty, string.Empty);
+ getWerReportingFilesTask.Wait();
+
+ Assert.AreEqual(TaskStatus.RanToCompletion, getWerReportingFilesTask.Status);
+
+ List list = getWerReportingFilesTask.Result.Files;
+ Assert.AreEqual(2, list.Count);
+ list.ForEach(file =>
+ {
+ Assert.IsFalse(string.IsNullOrWhiteSpace(file.Name));
+ Assert.AreNotEqual(0, file.Size);
+ });
+ }
+ }
+}
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/WebSocket_api_etw_session_realtime_Default.dat b/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/WebSocket_api_etw_session_realtime_Default.dat
new file mode 100644
index 00000000..f7bcb871
--- /dev/null
+++ b/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/WebSocket_api_etw_session_realtime_Default.dat
@@ -0,0 +1 @@
+{ }
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_etw_customproviders_Default.dat b/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_etw_customproviders_Default.dat
new file mode 100644
index 00000000..d332e2d4
--- /dev/null
+++ b/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_etw_customproviders_Default.dat
@@ -0,0 +1 @@
+{"Providers" : [{"GUID" : "3A43D90E-530E-41E5-A897-B555516070E2", "Name" : "Provider.One"},{"GUID" : "52B1715B-5AB6-4B48-A61A-A93EE8D4B5CD", "Name" : "Provider-Two"},{"GUID" : "698F02FF-2B63-4CBB-AB06-FEB88011347E", "Name" : "Provider.Three"}]}
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_etw_providers_Default.dat b/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_etw_providers_Default.dat
new file mode 100644
index 00000000..d332e2d4
--- /dev/null
+++ b/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_etw_providers_Default.dat
@@ -0,0 +1 @@
+{"Providers" : [{"GUID" : "3A43D90E-530E-41E5-A897-B555516070E2", "Name" : "Provider.One"},{"GUID" : "52B1715B-5AB6-4B48-A61A-A93EE8D4B5CD", "Name" : "Provider-Two"},{"GUID" : "698F02FF-2B63-4CBB-AB06-FEB88011347E", "Name" : "Provider.Three"}]}
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_wer_report_files_Default.dat b/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_wer_report_files_Default.dat
new file mode 100644
index 00000000..5af22c47
--- /dev/null
+++ b/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_wer_report_files_Default.dat
@@ -0,0 +1 @@
+{"Files" : [{"Name" : "DMI59C3.tmp.log.xml", "Size" : 17490},{"Name" : "Report.wer", "Size" : 2354}]}
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_wer_reports_Default.dat b/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_wer_reports_Default.dat
new file mode 100644
index 00000000..fd900ce2
--- /dev/null
+++ b/WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_wer_reports_Default.dat
@@ -0,0 +1 @@
+{"WerReports" : [{"User" : "All Users", "Reports" : []},{"User" : "Default", "Reports" : []},{"User" : "Default User", "Reports" : []},{"User" : "defaultuser0", "Reports" : []},{"User" : "Public", "Reports" : []},{"User" : "SYSTEM", "Reports" : [{"CreationTime" : 131318340058889142, "Name" : "NonCritical_x64_7929388dba23a244febb598fddbb379b5a87d15_00000000_cab_03f96433", "Type" : "Queue"},{"CreationTime" : 131318340058732887, "Name" : "NonCritical_x64_bf8ef24cbbad37c50f759d68f2292f1f2b0e7df_00000000_cab_03f96423", "Type" : "Queue"},{"CreationTime" : 131318550054539960, "Name" : "NonCritical_x64_f52a5825f740cca45c7b0c8078746ec73beaac_00000000_18add298", "Type" : "Archive"},{"CreationTime" : 131318340063576709, "Name" : "NonCritical_x64_f728cd6f9e9f34997130a4d3dd3d855648a6f_00000000_0ca56608", "Type" : "Archive"}]}]}
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/UnitTestProject.csproj b/WindowsDevicePortalWrapper/UnitTestProject/UnitTestProject.csproj
index 5f96bccb..f3f1c29f 100644
--- a/WindowsDevicePortalWrapper/UnitTestProject/UnitTestProject.csproj
+++ b/WindowsDevicePortalWrapper/UnitTestProject/UnitTestProject.csproj
@@ -62,6 +62,8 @@
+
+
@@ -85,9 +87,24 @@
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestDelete.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestDelete.cs
index 773180df..05019cda 100644
--- a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestDelete.cs
+++ b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestDelete.cs
@@ -43,7 +43,7 @@ private async Task DeleteAsync(Uri uri)
{
if (!response.IsSuccessStatusCode)
{
- throw new DevicePortalException(response);
+ throw await DevicePortalException.CreateAsync(response);
}
if (response.Content != null)
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestGet.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestGet.cs
index bca5ee88..c3e45d45 100644
--- a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestGet.cs
+++ b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestGet.cs
@@ -44,7 +44,7 @@ private async Task GetAsync(
{
if (!response.IsSuccessStatusCode)
{
- throw new DevicePortalException(response);
+ throw await DevicePortalException.CreateAsync(response);
}
using (HttpContent content = response.Content)
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPost.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPost.cs
index 6fa1755e..87423035 100644
--- a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPost.cs
+++ b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPost.cs
@@ -56,7 +56,7 @@ private async Task PostAsync(
{
if (!response.IsSuccessStatusCode)
{
- throw new DevicePortalException(response);
+ throw await DevicePortalException.CreateAsync(response);
}
if (response.Content != null)
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPut.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPut.cs
index d0f89aab..98c38a8d 100644
--- a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPut.cs
+++ b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPut.cs
@@ -47,7 +47,7 @@ private async Task PutAsync(
{
if (!response.IsSuccessStatusCode)
{
- throw new DevicePortalException(response);
+ throw await DevicePortalException.CreateAsync(response);
}
if (response.Content != null)
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/WebSocket.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/WebSocket.cs
index 8a499e7c..5439b300 100644
--- a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/WebSocket.cs
+++ b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/WebSocket.cs
@@ -36,6 +36,11 @@ internal partial class WebSocket
///
private Func