public async Task TurnOnWemoPlugAsync_VerifyAsync() { // ARRANGE var ipAddress = "http://192.168.1.44444"; // Acquire the soap/Xml data that we wish to supply within our mock'd HttpWebRequest and HttpWebResponse // Read Text directly instead of Bytes - so that our Xml comparison is easier (aka, BOM) var getBinaryStateResponseBytes = Encoding.UTF8.GetBytes(File.ReadAllText("TestData\\GetBinaryStateResponse.xml")); // Mock the HttpWebRequest and HttpWebResponse (which is within the request) var mockGetResponseWebRequest = CreateMockHttpWebRequest(HttpStatusCode.NotModified, "A-OK", getBinaryStateResponseBytes); var setBinaryStateResponseBytes = Encoding.UTF8.GetBytes(File.ReadAllText("TestData\\SetBinaryStateResponse.xml")); // Mock the HttpWebRequest and HttpWebResponse (which is within the request) var setWebRequest = CreateMockHttpWebRequest(HttpStatusCode.NotModified, "A-OK", setBinaryStateResponseBytes); var wemo = new Wemo { // Minimal inversion of control: // Set the WebRequest properties to provide our own Mock'd HttpWebRequest/Response GetResponseWebRequest = mockGetResponseWebRequest, SetResponseWebRequest = setWebRequest }; // ACT var result = await wemo.TurnOnWemoPlugAsync(ipAddress); // ASSERT Assert.IsTrue(result, "WemoPlug not turned on"); }
public async Task TurnOnWemoPlug_Verify() { // ARRANGE var ipAddress = "http://192.168.1.5"; var wemo = new Wemo(); // ACT var result = await wemo.TurnOnWemoPlugAsync(ipAddress); // ASSERT Assert.IsTrue(result, "The switch toggle command was not successful as expected"); }
public void TurnONPlug() { _wemo.TurnOnWemoPlugAsync(MistyApiInfo.WemoDeviceIpAddress).GetAwaiter().GetResult(); }